Few words on how to compare integers

Before I say anything I want to share with you a code snippet that is a simplified version of something I have recently wrote in my work. There is a small, yet painful bug in this code… can you see it?

public static class Point implements Comparable<Point> {
private int x, y;

[...]

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 [...]

Type safety in Java Set and Map

Probably many of you still remember the lack of type checking in Java 1.4 Collections and how much hassle it was to deal with casting the collection elements, not to mention how many errors this introduced to the code. Since introduction of generics in Java 1.5 this have really improved and one might think that [...]