Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 > E max(ArrayList list)

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database System

Authors: Elmasri Ramez And Navathe Shamkant

7th Edition

978-9332582705

More Books

Students also viewed these Databases questions