This question is based on the Collection Framework and Generics.
-
You should implement a generic class, call MyMathClass , with a type and value parameter T, V where V is a numeric object type (e.g., Integer, Double, or any class that extends java.lang.Number )
-
Implement a method named Average that takes a HashMapt of type T, V and calculate the average of the HashMap values and display. Hint: use doubleValue () method in the Number class to retrieve the value of each number as a double.
-
Implement another method call ConvertTo which convert and store HashMap values to an ArrayList. Method should takes a HashMapt of type T, V and return the ArrayList.
-
Implement a class call Mymain which having the main method and test Average and ConvertTo methods with suitable data. Your program should generate a compile-time error if your Average is invoked on a HashMap that is defined for nonnumeric elements as value parameter (e.g., <Strings, String>).