Author | Topic: equals in wrapper class |
shan unregistered |
posted February 20, 2000 11:51 AM
I am still confused with the equals method functioning ?? I am still not able to catch why it is behaving so differently in wrapper classes??
Object A = new Long(7);
|
maha anna bartender |
posted February 20, 2000 12:11 PM
Long l1 = new Long(7); Integer j = new Integer(7); System.out.println(l1.equals(j));//false???? //See carefully! here l1-->Long j --->Integer //Both refs are diff class types . So it is false. Object A = new Long(7); Long l2 = new Long (7); System.out.println(A.equals(l2));//true //Now see here!! A-->Object l2 --->Long (Implicitly Object) For the Wrapper classes's equal(Object o) to return true the argument and the ref types MUST be same class type
|
shan unregistered |
posted February 20, 2000 01:25 PM
thanx I got it....
|
| | |