Click to See Complete Forum and Search --> : need help in java


indianj
09-29-2005, 09:02 PM
hello everyone, i was going through exercise in book and here is the part i need some help.

Consider this code that creates some location objects with coordinates x=10 and y=20:

Location a, b, c;
a=new Location (10,20);
b=new Location (10,20);
c=b;

after this code executes, what are the values of these boolean expressions?

A= =b
a.equals(b)
a= =c
a.equals(c)
b= =c
b.equals(c)

jwlnewsome
10-05-2005, 08:32 AM
take a look at http://www.geocities.com/technofundo/tech/java/equalhash.html

i think you will find x.equals(y) is the only one that works with objects but its been a while so check it out :eek:

buntine
10-05-2005, 10:12 PM
Why not write up a small program and find out? Just use System.out.println() to view the boolean value of each expression.

Regards.