The first thing to do is read the API doc for the ArrayList class and see if any of its methods will do what you want.