I am writing the image processing program, and I have a problem with a list.
I have a list with Points.
class Point1{
private int x;
private int y;
Point1(int x,int y)
{
this.x = x;
this.y = y;
}
int getX(){ return this.x; }
int getY() {return this.y; }
}
ArrayList<Point1> list = new ArrayList();
And now, I create new Point, for example new Point(4,3); I want to check if there is a point in my list which has the same coordinates. The problem is that
list.contains(Object a)
is checking if if on my list there is a particular object. It will work if I put
Point1 first = new Point(1,1);
list.add(first);
list.contains(first) // and this is true
but:
Point second = new Point(2,2);
list.add(second);
list.contains(new Point(2,2)); <- false
how can I check it?