If the ==
operator returns a true
will the equals()
method
return a true, always?
Yes.
The following table summarizes what you have just slept through. Assume that each row is independent of the others.
code section | pointA == pointB | pointA.equals( pointB ) |
---|---|---|
Point pointA = new Point( 21, 17 ); Point pointB = new Point( 21, 17 ); |
false | true |
Point pointA = new Point( 21, 17 ); Point pointB = new Point( -99, 86 ); |
false | false |
Point pointA = new Point( 21, 17 ); Point pointB = pointA; |
true | true |