In PacMan DFS problem i represent each points with the following static ier class
static class Point{
int x;
int y;
public Point(int x, int y){
this.x = x;
this.y = y;
}
public boolean equals(Point p){
System.out.println(this+", "+p);
retu (this.x == p.x && this.y == p.y) ? true: false;
}
public String toString(){
retu x+" "+y;
}
}
and add each point in ArrayList points = ArrayList();
problem is: if i do the following points.contains(new Point(1, 2)) equals(method) never invoked although points.size() > 0;
i case you don't know: contains invoke ArrayList.indexOf --> run though each point and compare by using equals if equals retu num>-1 else retu -1, but indexOf never reach equals in contains(point) if point is null.
