Question: Write the following generic method that sorts an ArrayList of Comparable items. The sort method must use the compareTo method. public static > void sort
Write the following generic method that sorts an ArrayList of Comparable items.
The sort method must use the compareTo method.
public static void sortArrayList list
Write a test program that:
prompts the user to enter integers, invokes this method to sort the
numbers, and displays the numbers in ascending order
prompts the user to enter strings, invokes this method to sort the strings,
and displays the strings in ascending alphabetical order
Your output should look like that below:
Enter integers:
The sorted numbers are:
Enter strings: these are my five strings
The sorted strings are: are five my strings these
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
