I thought equals() method was overriden (ie. was performing "deep" comparison) only in String and Boolean wrapper classes. Now I encountered an example in Poddar Questions where Double seems to overriding equals() as well... What is finally the list of all wrapper classes overriding Object's equals() method? Thank you!!
OK, so all of the following wrapper classes: Boolean, String, Double, Integer, Float, Byte, Short and Long DO OVERRIDE Object's equals() method (and therefore do "deep" comparios) while it's ONLY StringBuffer class that doesn't override it and for StringBuffer objects equals() and == have the same effect. Is that right? Thanks!!!
As StringBuffer does not override the equals() method of the Object class. It has theinherited behaviour of the equals() in the Object. Which simply does a == comparison. So sb==sb and sb1==sb1 will return true and so will the equals method. As in