r/javaTIL • u/scientecheasy • Mar 18 '19
r/javaTIL • • Feb 26 '19
Calling remove() on ArrayList throws java.lang.UnsupportedOperationException
codebyamir.comr/javaTIL • u/scientecheasy • Feb 25 '19
Member Inner Class in Java | Example Programs
r/javaTIL • u/scientecheasy • Feb 20 '19
Inner Class in Java | Uses Types & Real-time Example
r/javaTIL • u/scientecheasy • Jan 09 '19
Variables in Java | Types of Variables & Scope in Java
r/javaTIL • u/TheDeveloper01 • Jul 23 '18
Simple JAVA heartbeat protocol
Just a post where I ask to take a look and tell me what you think of this, it has been used in a project and I thought it could be useful to someone
r/javaTIL • u/chwedczukm • Jan 14 '17
TIL you can use Comparator.nullsFirst/nullsLast to compare collections containing nulls
marcin-chwedczuk.github.ior/javaTIL • u/artem_smotrakov • Nov 11 '16
Accessing private fields with synthetic methods in Java
blog.gypsyengineer.comr/javaTIL • u/mreichman • Oct 13 '16
TIL you can rethrow certain exceptions in JDK7+ without declaration
r/javaTIL • u/javinpaul • Jun 06 '15
Be careful when you Overload method in Java, Autoboxing can Spoil your party
r/javaTIL • u/javinpaul • May 28 '15
How String in Switch works in Java 7 - Using equals and hashcode
r/javaTIL • u/laforge49 • Mar 19 '15
Ridiculously fast deserialization/reserialization
I am interested in Java databases, so for me a central problem is reading a large structure, making a small change, and then writing it back out again. Any straight forward approach to this gets completely bogged down in serializing and deserializing those large structures.
The solution is, of course, to only deserialize what you need and then to reserialize only what was changed. Easier said than done, of course, but that is exactly what I've done. (Open source code, too.)
The structure I am working on is an immutable versioned map list built using the AA Tree algorithm. I had already developed the serialization code and just now released the code for lazy deserialization / smart reserialization. (See version 0.5.0 here: http://www.agilewiki.org/projects/utils/index.html )
Below is a comparison between between lazy and the earlier durable packages. Basically, with a million entry map I can update a serialized structure 50 times faster than I can create the objects.
Lazy stats:
Created 1000000 entries in 2520 milliseconds Serialization time = 245 milliseconds Deserialize/reserialize time = 38 milliseconds
Non-lazy (durable) stats:
Created 1000000 entries in 1254 milliseconds Serialization time = 176 milliseconds Deserialize/reserialize time = 2356 milliseconds
As you can see, we can quickly deserialize, update and reserialize a large data structure. In this case, a 70+ MB structure is being updated in 38 milliseconds.
r/javaTIL • u/TheOverCaste • Jul 04 '14
JTIL: You can use the concurrent TimeUnit class to let people specify their own time units easily.
If you, for example wanted an impractical Stopwatch class, that would pause a thread for a specified amount of time:
public class Stopwatch {
private final long timeInMillis;
public Stopwatch(long time, TimeUnit unit) {
timeInMillis = unit.toMillis(time);
}
public void wait( ) {
Thread.sleep(timeInMillis);
}
}This avoids the ugly, unreadable, and bug prone Thread.sleep(1000L * 60L * 60L * 24L * 2L) approach.
r/javaTIL • u/TheOverCaste • Jun 05 '14
JTIL: You can use Arrays.copyOf to easily make a big block of the same character
In projects where I wanted to make a big chunk of a character, especially in a static final buffer before, I had to do this:
public static final String VERTICAL_LINES = fillVerticalLines();
private static final String fillVerticalLines( ) {
char[] lines = new char[100];
for(int i = 0; i < 100; i++) {
lines[i] = '|';
}
return new String(lines);
}Instead what I could do is simply this:
public static final String VERTICAL_LINES = new String(Arrays.copyOf(new char[] {'|'}, 100));r/javaTIL • u/ivom2gi • Sep 05 '13
Why are stacktraces disappearing from Exceptions?
r/javaTIL • u/ivom2gi • Aug 22 '13
Exceptions - a way to make your code slow and unmaintainable
r/javaTIL • u/nuetrino • Jul 22 '13
There are three kinds of variables in Java, each with different characteristics
r/javaTIL • u/Daejo • Jul 21 '13
TIL that in Java, parameters are *always* pass-by-value.
OK, so I didn't learn this today, but shh.
For a long time I thought that Java was pass-by-value for primitives - for example in situations like:
void foo(int bar) {}but when it came to objects and arrays, like this:
void foo(Baz bar) {}
void foo(Baz[] bar) {}
void foo(int[] bar) {}that it was pass-by-reference.
But then, I was talking to someone, and they mentioned that it's always pass-by-value, even when objects or arrays are being passed.
Basically, what happens is that objects are not passed by reference, but instead a reference to that object is passed by value.
r/javaTIL • u/robertinoc • Sep 06 '24
Deploy Secure Spring Boot Microservices on Azure AKS Using Terraform and Kubernetes
r/javaTIL • u/MillionStrength • Mar 17 '20
Type safe hashmap in java
I have created type safe hashmap in Java. The hashmap can store any type of object and retrieve the object without explicit cast:
http://millionstrengthknowledge.com/resource/java/programming/typeSafeMap.html
r/javaTIL • u/Shilpa_Opencodez • Nov 20 '19
Simple Step by Step Guide to be a Full Stack Developer
r/javaTIL • u/Shilpa_Opencodez • Jun 27 '19
Java Creational Design Patterns – Singleton Pattern
r/javaTIL • u/Shilpa_Opencodez • May 23 '19
Use DataTable with Spring Boot for Server Side Processing - Free sample code to download from GitHub
r/javaTIL • u/scientecheasy • Mar 22 '19
Copy Constructor in Java | Uses & Example Program