ArrayListApp
class that plays with an ArrayList
. The app should:
ArrayList
of <Integer> and populate it with random integers:
java ArrayListApp <howMany> <range>
ArrayList
should the be printed (using toString
)
ArrayList
using bubble sort
ArrayList
again
0 … range-1
)
and for each one, print whether it is contained in the ArrayList
ArrayList
that is a copy of the first (use the copy constructor — it takes an ArrayList
aa it argument. If you look it up in the API, it's the constructor that has a Collection
parameter.)
ArrayList
by repeatedly removing the first element; print the removed element and the ArrayList
as you go along.
ArrayList
by repeatedly removing the last element; print the removed element and the ArrayList
as you go along.
ArrayList
Here is the expected output (for CodeLab):
Playing with an ArrayList containing 10 numbers in the range of 0..20 Before sorting [11, 0, 1, 8, 15, 4, 15, 2, 1, 9] After sorting [0, 1, 1, 2, 4, 8, 9, 11, 15, 15] 0 is in the list 1 is in the list 2 is in the list 3 is not in the list 4 is in the list 5 is not in the list 6 is not in the list 7 is not in the list 8 is in the list 9 is in the list 10 is not in the list 11 is in the list 12 is not in the list 13 is not in the list 14 is not in the list 15 is in the list 16 is not in the list 17 is not in the list 18 is not in the list 19 is not in the list [0, 1, 1, 2, 4, 8, 9, 11, 15, 15] Removing from front removed 0: [1, 1, 2, 4, 8, 9, 11, 15, 15] removed 1: [1, 2, 4, 8, 9, 11, 15, 15] removed 1: [2, 4, 8, 9, 11, 15, 15] removed 2: [4, 8, 9, 11, 15, 15] removed 4: [8, 9, 11, 15, 15] removed 8: [9, 11, 15, 15] removed 9: [11, 15, 15] removed 11: [15, 15] removed 15: [15] removed 15: [] [0, 1, 1, 2, 4, 8, 9, 11, 15, 15] Removing from rear removed 15: [0, 1, 1, 2, 4, 8, 9, 11, 15] removed 15: [0, 1, 1, 2, 4, 8, 9, 11] removed 11: [0, 1, 1, 2, 4, 8, 9] removed 9: [0, 1, 1, 2, 4, 8] removed 8: [0, 1, 1, 2, 4] removed 4: [0, 1, 1, 2] removed 2: [0, 1, 1] removed 1: [0, 1] removed 1: [0] removed 0: []
ArrayList