Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java Write a generic class named MyList, with a type parameter T. The type parameter T should be constrained to an upper bound: the Number

Java

Write a generic class named MyList, with a type parameter T. The type parameter T should be constrained to an upper bound: the Number class. The class should have as a field an ArrayList of T. Write a public method named add, which accepts a parameter of type T. When an argument is passed to the method, it is added to the ArrayList. Write two other methods, largest and smallest, which return the largest and smallest values in the ArrayList.

Create two isntances of the above class like shown below and insert bunch of Number into MyList of type Number and bunch of Double into Mylist of type Double.

Then call largest() and smallest() methods in each of the above class.

You can insert the following integer numbers into the list 2

5

-13

11

12

And insert the following double numbers:

27.3

5.7

-23.9

1.11

5.12

Here is the sameple input/outPut

PART 1 The Integer largest: 12 The Integer smallest: -13 The Double largest: 27.3 The Double smallest: -23.9

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

More Books

Students also viewed these Databases questions

Question

2. Identify issues/causes for the apparent conflict.

Answered: 1 week ago

Question

3. What strategies might you use?

Answered: 1 week ago