I've the following Object,
public class Pair {
    private int row;
    private int col;
    public Pair(int row, int col){
        this.row = row;
        this.col = col;
    }
    public int getRow(){
        return row;
    }
    public int getCol(){
        return col;
    }
}
I'm storing these pairs in a queue, but wan't to check if the Queue contains the Pair already. This is my code.
Queue<Pair> queue = new LinkedList<>();
if(!queue.contains(new Pair(curr.getRow(), curr.getCol()){
 //do something
}
This is not working and the Queue is storing duplicate values. Can someone help mw understand why and what's the way to fix it?
 
     
     
    