Matt,
== compares object references for reference equality and primitive value for value equality, i.e.
Object o1 = new Object();
Object o2 = new Object();
Object o3 = o1;
o1==o2 yields false;
o1==o3 yields true;
int i1 = 1;
int i2 = 1;
int i3 = 2;
i1==i2 yields true
i1==i3 yields false
Now concerning equals, first of all, equals can only be applied to object references since it is a method.
You should always override the equals method in your classes in order to provide a correct equality
test for your objects since the equals method in Object just returns the result of an == test. Moreover, only objects of the same class should be compared equal, that is you cannot compare a Long and a Integer for equality.
Long l = new Long(1);
Integer i = new Integer(1);
l.equals(i) or i.equals(l) yields false
HIH
------------------
Valentin Crettaz
Sun Certified Programmer for
Java 2 Platform
[This message has been edited by Valentin Crettaz (edited November 20, 2001).]
[This message has been edited by Valentin Crettaz (edited November 20, 2001).]