title: Java arraylist indexof
body: <p>Here is my class <code>animals.java</code>:</p>
  
  <pre><code>public class animals {
      String Name, ID;
      static ArrayList&lt;animals&gt; animalData = new ArrayList&lt;animals&gt;();
  
      public animals(){}
      public animals(String name, String id){
          super();
          this.Name = name;
          this.ID = id;
      }
  
      public void addAnimal(String name, String id){
          animalData.add(new animals(name, id));
      }
  
      public int search(String name){
          return this.animalData.indexOf(name);
      }
  }
  </code></pre>
  
  <p>When I add an animal name with an id it works normally, but when I use search method I saw only -1. Maybe I try override method <code>equals</code> or <code>indexof</code> in this class? help me for this</p>
  
  <p>Thank you and sorry for my bad english..</p>