Whenever we override the equals() method in any class, we must also override the hashCode() method.
if(o1.equals(o2))
then
o1.hashCode() == o2.hashCode()
must also be true.
For more details - http://www.ibm.com/developerworks/java/library/j-jtp05273.html
Wednesday, September 24, 2008
Creating Booleans
FindBugs suggests that we should not instntiate Boolean objects like this
Boolean b = new Boolean(false);
instead we must use the creational method
Boolean b = Boolean.valueOf(false);
This is better for performance, since the Boolean object caches 2 immutable Booelan objects for true and false values.
Boolean b = new Boolean(false);
instead we must use the creational method
Boolean b = Boolean.valueOf(false);
This is better for performance, since the Boolean object caches 2 immutable Booelan objects for true and false values.
Subscribe to:
Posts (Atom)