title: Replacing an object in a ArrayList
body: <p>I need to know how to replace an object which is in a <code>ArrayList&lt;Animal&gt;</code>.</p>
  
  <p>I have a array list called <code>ArrayList&lt;Animal&gt;</code>. This list only has 5 animals listed init.</p>
  
  <pre><code>Animal animal = new Animal();
  animal.setName("Lion");
  animal.setId(1);
  
  ArrayList&lt;Animal&gt; a = new ArrayList&lt;Animal&gt;();
  
  a.put(animal); // likewise i will be adding 5-6 animals here.
  </code></pre>
  
  <p>Later on, i will take an object from this array list and modify it.</p>
  
  <pre><code>Animal modifiedAnimal = new Animal();
   animal.setName("Brown Lion");
      animal.setId(1);
  </code></pre>
  
  <p>Now i need to add this Animal Object to the <code>ArrayList&lt;Animal&gt; a</code>   array list. I need it to replace the previous <code>Animal</code> object which we named it <code>Lion</code>. How can i do this ?</p>
  
  <p>Note: I don't know the Index where this object is added.</p>