You are only modifying one object. Are all the objects the same as the last input item? I'd imagine they are. You are storing the references to the objects in the array list. The elements of the array list point to the object on the heap. Since they are all the same item(this), the calls to setXxxx are just modifying the object referenced by this.
Luckily, there is an easy solution. First, get and store the information in strings, int, other primitives that make up the class. Then create an item with a constructor
This should work as you want it to.Code:
AddressBook ab = new AddressBook(/*use the stored arguments in the constructor*/);
edit: I said array list in my explanation, just replace all occurrence of array list with vector.
Dratted cross poster
Storing objects (Beginning Java forum at JavaRanch)
Im sorry. I glanced at the forum rules in the past and I didnt remember that rule. I was just trying to get a quick answer.
I know the post is about a day old, but to the op, don't remove your questions, it could end up answering other peoples questions in the future. Instead mark the thread solved with the thread tools at the top of the page.