I am using the contains
method to check whether given coordinates are present in the list or not. The output of the above code should be "Yes"
but I am getting "NO"
. Can anybody help me with this?
class points {
public int x;
public int y;
public points(int x,int y){
this.x=x;
this.y=y;
}
}
class GFG {
public static void main (String[] args) {
ArrayList<points> point = new ArrayList<points>();
points p= new points(1,1);
points q= new points(2,2);
point.add(p);
point.add(q);
if(point.contains(new points(1,1))){
System.out.println("Yes");
}
else{
System.out.println("NO");``
}
}
}