Question: (Java Programming) Create an array of six USA state names using the array initializer syntax. Then, create an ArrayList from this array. Add two more
(Java Programming) Create an array of six USA state names using the array initializer syntax. Then, create an ArrayList from this array. Add two more state names to this list, and then use a foreach loop to display the state names all on one line separated by spaces. Next, use the Collections class to sort the list, and display the sorted list with a foreach loop as before. Display the 5th element in the sorted list. Deletethe state at index 6 and identify which state was removed. Finally, use a for loopto display the list in its final form, all elements on one line separated by spaces. See Sample Output below.
Sample Output
States I entered
Florida Vermont Oregon Virginia Kansas Arizona Texas New York
States list sorted
Arizona Florida Kansas New York Oregon Texas Vermont Virginia
The 5th state in my list is Oregon
Deleted state Vermont
Here is my final list of states
Arizona Florida Kansas New York Oregon Texas Virginia
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
