Carlos' reply is almost irelevant to the question - for two reasons:
a) Note that
Integer i = 24;
is NOT same as
Integer i = new Integer(24);
Whatever Carlos has pointed out (special cases etc) holds for the former case, not in the later case.
b) Carlos talks about "==", which is different than what Xiao is talking about - the equals() method.
Coming back to the question posted by Xiao, The class Integer overrides "equals" method so that any two integers with the same numeric value are considered "equal". As a result, see that
Integer i = new Integer(344); Integer j = new Integer(344); System.out.println(i.equals(j)); //true.
On the other hand, the class Value doesnot override the equals() method. The equals() method, as defined in the "Object" class returns the same result as "==". Since two different value instances are never "==", hence the equals() method will return false.
The equals method for class Object implements the most discriminating possible equivalence relation on objects; that is, for any non-null reference values x and y, this method returns true if and only if x and y refer to the same object (x == y has the value true).
As far as the exact "implementation" of equals() method is concerned,I am not sure whether Object class is implemented in java or in a native language like C.
I just had the craziest dream. This tiny ad was in it.
a bit of art, as a gift, the permaculture playing cards