Here is a replication of code that appears on pg 104 of 'thinking in
java'
public class EqualsMethod{
public static void main(String[] args){
Integer n1 = Integer(47);
Integer n2 = Integer(47);
System.out.println(n1.equals(n2));
}
}
The result of the above will be true.
class Value{
int i;
}
public class EqualsMethod2{
public static void main(String[] args){
Value v1 = new Value();
Value v2 = new Value();
v1.i = v2.i = 100;
System.out.println(v1.equals(v2));
}
}
the result of the above is false
I fail to understand how the second result is false. Could someone kindly explain.
THANKS.