Basic ArrayLists 1

Create an ArrayList that can hold Integers. Add ten copies of the number -2327 to the ArrayList. Then display the contents of the ArrayList on the screen.

This time, you must use a loop, both to fill up the ArrayList and to display it. Also, in the condition of your loop, you should not count up to a literal number. Instead you should use the size() of your ArrayList.

(It is okay to use a number instead of the size() method to add() the values to the ArrayList, but not to display them.

Slot 0 contains a -2327
Slot 1 contains a -2327
Slot 2 contains a -2327
Slot 3 contains a -2327
Slot 4 contains a -2327
Slot 5 contains a -2327
Slot 6 contains a -2327
Slot 7 contains a -2327
Slot 8 contains a -2327
Slot 9 contains a -2327



©2013–2015 Graham Mitchell

This assignment is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 United States License.
Creative Commons License