Reference Equality
Two references to objects are equal if they refer to one and the same object.
Example
What does the following code print?
class Foo{
int f = 6;
}
. . .
Foo p1 = new Foo();
Foo p2 = new Foo();
if ( p1 == p2 )
System.out.println(�equal�);
else
System.out.println(�not equal�);
Previous slide
Next slide
Back to first slide
View graphic version