title: Resize an Array while keeping current elements in Java?
body: <p>I have searched for a way to resize an array in Java, but I could not find ways of resizing the array <em>while keeping the current elements</em>.</p>
  
  <p>I found for example code like <code>int[] newImage = new int[newWidth];</code>, but this deletes the elements stored before.</p>
  
  <p>My code would basically do this: whenever  a new element is added, the array largens by <strong>1</strong>. I think this could be done with dynamic programming, but I'm, not sure how to implement it.</p>