I intend to override the boolean equals(Object otherObject)
method within my Pair class that utilizes a private inner class with private instance variables as follows:
class Pair
{
class Node
{
private int x, y;
}
public boolean equasl(Object otherObject)
{
if(otherObject == null)
{
return false;
}
else if(getClass() != otherObject.getClass())
{
return false;
}
else
{
Pair other = (Pair)otherObject;
return (x.equals(otherObject.x) && y.equals(otherObject.y));
}
}
}
It is not clear to me how I am comparing two Pair
objects in which each object is comprised of a doubly-linked list (not shown for clarity). Am I comparing each object beginning with the head node and traversing the lists verifying that each node in the lists are equal?