February 23, 2014

Date and Calendar Members Are Modifiable


The Date and Calendar classes are mutable classes. If you use them as a class variable and return them via accessor methods ("getters"), the client class can modify them, even if they are private members.

February 15, 2014

HashMap vs. equals()


You might face exam questions asking what happens when adding certain objects to a map. For this you have to understand what the equals() and hashCode() methods do, what is the contract of the Map collection and how its widely used implementation HashMap works.

February 8, 2014

Simple Java Deadlock Example Explained


There are several good Java deadlock examples on the internet. I tried to write the simplest example which is readable and also executable. I used the deadlock example in the Java Tutorial, which I had to re-write, because it did not always produced a deadlock when executed with JUnit: