title: How to return an object after removing it from an ArrayList?
body: <p>I was thinking of doing it like this, but I'm not sure if the reference temp is assigned will still be valid after removal.</p>
  
  <pre><code>public Box removeBox(int index)
  {
  Box temp=getBoxes().get(index);//ArrayList.get
  getBoxes().remove(index);
  return temp;
  }
  </code></pre>