// DrJava saved history v2 Student a = new Student("Andrew" , "T"); Student b; /* we are assigning the value in a to b */ /* but b only holds a reference (memory location) to a Student in memory */ b = a; int c = 5; int d = 5; c == d d == 4 d = 4 c == d /** does the value in a equal that in b? */ a == b /* yes - they both refer to the same object */ b = new Student("Andrew" , "T"); /* we just created an identical Student object and assigned it to b */ /* are they equal this time? */ a == b /* no, because == tests if they hold equivalent references, and */ /* a refers to the location of the first student object we created */ /* and b now refers to the new student object */ String e = "faye"; String f = "faye"; /* what about strings? */ e == f /* to compare string values, we use the equals(Object o) method */ /* look it up in the API documentation for java.lang.String */ e.equals(f) Student a = new Student("Andrew" , "T"); Student b = new Student("Andrew" , "T"); a == b a.equals(b)