title: checking if list contains the object - java
body: <p>I am writing the image processing program, and I have a problem with a list.</p>
  
  <p>I have a list with Points.</p>
  
  <pre><code>     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&lt;Point1&gt; list = new ArrayList();
  </code></pre>
  
  <p>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 </p>
  
  <pre><code>    list.contains(Object a) 
  </code></pre>
  
  <p>is checking if if on my list there is a particular object. It will work if I put</p>
  
  <pre><code>    Point1 first = new Point(1,1);  
      list.add(first);
      list.contains(first) // and this is true
  </code></pre>
  
  <p>but:</p>
  
  <pre><code>    Point second = new Point(2,2);
      list.add(second);
      list.contains(new Point(2,2)); &lt;- false
  </code></pre>
  
  <p>how can I check it?</p>