Question: 1)- MyList Class *java using BigDecimal* Write a generic class named MyList, with a type parameter T. The type parameter T should be constrained to

1)- MyList Class *java using BigDecimal*

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 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. Demonstrate the class in an application.

import java.util.*; import java.math.BigDecimal;

public class MyList { private ArrayList num = new ArrayList();

public static T Largest() { }

public static T Smallest() { }

public static void add(T a) { a.add(1); a.add(5); a.add(9); a.add(-1); for(T k : a) { BigDecimal bd = new BigDecimal(num); } }

public static void main(String args[]) { } }

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 Databases Questions!