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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started