title: Java how to check if an object in an arraylist contains a certain value
body: <p>Hello I have a programme where you place tiles to build houses and then you sell the houses. I only want to sell the houses if the building has a door an at least one window.
  My arraylist looks like this:</p>
  
  <pre><code>   public static ArrayList&lt;block&gt; b = new ArrayList&lt;block&gt;();
  </code></pre>
  
  <p>every type of tile has an id. the door tile is 1 and the windows tile is 2 and the wall tile is 3.</p>
  
  <pre><code>for(int i = 0; i &lt; play.b.toArray().length;i++){
      if(play.b.contains(play.b.get(i).id == 1)){
          cansell= true;
      }else{
          cansell= false;
      }
  
  }
  </code></pre>
  
  <p>How can I check to see if an object in an arraylist contains a certain value , in this case the value 1.</p>
  
  <p>here is the door class:</p>
  
  <pre><code>public class door extends block{
  
  
      public cockpit(int x,int y,int rot){
          this.x = x;
          this.y = y;
          this.rotate = rot;
          r = new Rectangle(x - (int)play.camx,y - (int)play.camy,20,20);
          id = 3;
      }
  
      public void tick(){
          createCollisionRect();
  
          if(Comp.mr &amp;&amp; r.contains(new Point((Comp.mx ) ,(Comp.my) ))){
              remove = true;
  
          }
          if(remove){
              //play.gui.money +=800;
  
          }
  
      }
  
      public void render(Graphics g){
          Graphics2D g2 = (Graphics2D) g;
  
          if (rotate == 0) {
              ImageIcon i62 = new ImageIcon("res/tiles/cockpit.png");
              img = i62.getImage();
              g.drawImage(img, x - (int) play.camx, y - (int) play.camy,20,20, null);
          }
          if (rotate == 1) {
              AffineTransform at = AffineTransform.getTranslateInstance(x, y);
              at.rotate(Math.toRadians(90),10,10);
  
              ImageIcon i62 = new ImageIcon("res/tiles/cockpit.png");
              img = i62.getImage();
  
              g2.drawImage(img,at, null);
          }
          if (rotate == 2) {
              AffineTransform at = AffineTransform.getTranslateInstance(x, y);
              at.rotate(Math.toRadians(180),10,10);
  
              ImageIcon i62 = new ImageIcon("res/tiles/cockpit.png");
              img = i62.getImage();
  
              g2.drawImage(img, at, null);
          }
          if (rotate == 3) {
              AffineTransform at = AffineTransform.getTranslateInstance(x, y);
              at.rotate(Math.toRadians(-90),10,10);
  
              ImageIcon i62 = new ImageIcon("res/tiles/cockpit.png");
              img = i62.getImage();
  
              g2.drawImage(img, at, null);
  
          }
  
  
      }
  }
  </code></pre>