Question: Create a program that does the following: creates an ArrayList of integers prompts the user to enter integers and adds them to the ArrayList calls
Create a program that does the following:
creates an ArrayList of integers
prompts the user to enter integers and adds them to the ArrayList
calls the generic method max to print out the largest element in the ArrayList.
creates an ArrayList of Strings
prompts the user to enter Strings and adds them to the ArrayList
calls the generic method max to print out the largest element in the ArrayList.
Implements the following generic method that returns the largest element in an ArrayList:
public static
Have the program display the output to the console. Your output should be as shown in the below example:
Enter an integer to add to a list of integers, 0 to stop:
46
Enter an integer to add to a list of integers, 0 to stop:
3
Enter an integer to add to a list of integers, 0 to stop:
14
Enter an integer to add to a list of integers, 0 to stop:
0
The largest integer in the array is 46.
Enter a string to add to a list of strings, "done" to stop:
computer
Enter a string to add to a list of strings, "done" to stop:
science
Enter a string to add to a list of strings, "done" to stop:
rocks
Enter a string to add to a list of strings, "done" to stop:
done
The largest string in the array is science.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
