Eclipse Tips: Auto generate ‘final’ on your variable, field, and parameter

If you are reading a lot of blogs about Java lately, you’ll find more and more people suggesting to use ‘final’ everywhere. The main argument is by using ‘final’ we will have a code with less bug. This post will not argue with the up/down side of the suggestion, if you eager to do that, …

Lambda4JDT: lambda expression on your Java code

This is just another proof how many people are starting to want some functional syntaxes on Java. Some lambda expressions are possible to be implemented using current Java, but there are just too many noise in the result. Lambda4JDT provides a new plugin for Eclipse that can collapse the noise in the implementation without changing …

Java Tips: Optimizing your Map loop

Quite often, a program needs to go through all elements of a Map. Unfortunately, like a Set, a Map doesn’t have index in the data structure so you can’t just get a key of certain index or a value of certain index. The most common practice used to iterate all elements in a Map is …

Java Tips: Thread Safety Documentation

Joshua Bloch in his book, “Effective Java” summarized the levels of thread safety: immutable—Instances of this class appear constant. No external synchronization is necessary. Examples include String, Long, and BigInteger (Item 15). unconditionally thread-safe—Instances of this class are mutable, but the class has sufficient internal synchronization that its instances can be used concurrently without the …

Java Tips: Memory Optimization for String

String is a unique object in Java. The Java Specification explains several unique properties of String in Java. We might already know some of them. First, String is unique because it can be created without new keyword, like example below. I have to mention that you can still create String object using new keyword, like …

Java Tips: MessageFormat

Writing a working code is not enough. There is so wide spectrum from where we can distinguish good programmer and a bad one. This is one example of it. Suppose we need to write a String that concatenate several predefined substrings with several variables. What do we do? Obviously, the most natural thing is to …