Java ArrayList Contain always return false although it contain the same value

Viewed 24457

This is my Hole Class

class Hole {

public  int a;
public  int b;

Hole(int a, int b) {
    this.a = a;
    this.b = b;
}

So i adding an ArrayList that contain several several hole

public void checkPathLoop(int x, int y) {
        //rough code

        ArrayList<Hole> leftFlowInnerHole = new ArrayList<>();


        //left holes rules
        leftFlowInnerHole.add(new Hole(0, 1));
        leftFlowInnerHole.add(new Hole(1, 5));
        leftFlowInnerHole.add(new Hole(5, 4));
        leftFlowInnerHole.add(new Hole(0, 4));

when i add

Hole userInputHole = new Hole(0,1);
System.out.print(leftFlowInnerHole.contain(userInputHole));

it always return false !! it suppose to return true.

Is there anything i miss ??

Thank you in advance

4 Answers

This is not working

   if(priceidslist.contains(extraId)){
                               //Not working 
                            }

I just added this lines for checking that condition in (for -loop ),then its working fine

  String gh = String.valueOf(priceidslist.get(j));
                           if(gh.equals(extraId)){
                               rw.put("extraPrice",pricelist.get(j));
                           }
Related