title: How to check if an ArrayList contains an object from another class
body: <p>I have two classes, a <code>Fighter</code> class and a <code>Player</code> class. The <code>Player</code> class contains an <code>ArrayList</code> called <code>fleet</code> that is populated with a player's ships. </p>
  
  <p>I can add ships to the player's fleet without issue, but when I try check to see if a fighter is present in the player's fleet, it gives me an error saying <code>Fighter cannot be resolved to a variable</code>. </p>
  
  <p>I'm confused as to why I can add a Fighter to fleet, but can't check to see if a Fighter is present in fleet.</p>
  
  <p><strong>Fighter.java</strong></p>
  
  <pre><code>public class Fighter extends Ship {
      public Fighter(){
          super(9,1,1); //Sets attack and defense values
      }
  }
  </code></pre>
  
  <p><strong>Player.java</strong></p>
  
  <pre><code>import java.util.ArrayList;
  import java.util.Scanner;
  
  public class Player {
  
      ArrayList&lt;Ship&gt; fleet = new ArrayList&lt;Ship&gt;();
  
      public void takeAHit(){
          if (fleet.contains(Fighter)){                  //Error happens here
              System.out.println("Fighter found");
          }
      }
  
      public void buildFleet(){
  
          Scanner userInput = new Scanner(System.in);
  
          System.out.println("How many fighters?");
  
          int fighters = Integer.parseInt(userInput.next());
  
          while (fighters &gt; 0){
              fleet.add(new Fighter());
              fighters--;
          }
  
          userInput.close();
  
      }
  }
  </code></pre>
  
  <p><strong>Core.java</strong></p>
  
  <pre><code>public class Core {
  
      public static void main(String[] args) {
  
          Player p1 = new Player();
          p1.buildFleet();
          p1.takeAHit();
  
      }
  }
  </code></pre>