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 sort(ArrayList list)
Write a test program that:
1. prompts the user to enter 10 integers, invokes this method to sort the
numbers, and displays the numbers in ascending order
2. prompts the user to enter 5 strings, invokes this method to sort the strings,
and displays the strings in ascending (alphabetical) order
Your output should look like that below:
Enter 10 integers: 5379235487251227
The sorted numbers are: 3579122325275487
Enter 5 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 blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!