-
equals(object obj)
Hi there.
I don't understand the following Boolean:(plz some one explain it to me what it does.What is exactly onject and what does equals((point3)p ) do?)
-------------------------------------------------------------
public class Point3 extends Point2 {
private int z;
...
public boolean equals(Object p) { // overriding definition
if (p instanceof Point3) return equals((Point3)p);
return super.equals();
}
public boolean equals(Point2 p) { // overriding definition
if (p instanceof Point3) return equals((Point3)p);
return super.equals();
}
-
Quote:
equals((point3)p )
Casts p to type in () and calls the equals method with that type as an argument
What happens when you execute the code? Add some print statements to show how the compiler matched the code to the method.
-