Autoboxing pitfalls when comparing numbers with “==”

Here is a question for you. What happens when we compile and run the following code:

public class IntegerBig {
public static void main(String[] args) {
Integer a = 1000;
Integer b = 1000;
[...]

A reminder about remainder operator (%)

Today a short story about how a simple mathematical operation can ruin your whole day. This is something that I had the ‘pleasure’ of dealing with about 6 months ago, costed me 2 days of debuging and (as usual) turned out to be a surprising, yet basic Java feature. Because of that I believe it [...]

How to write a Singleton? (1/5)

It seems that Singleton from all design patterns is the most controversial one and people have drastically different views on whether or not it is useful. Many think it is in fact an antipattern and it does more harm than good. Personally I am not a big fan of singletons and it seems to me [...]