Question: Write a generic class, MyMathClass, with a type parameter T where T is a numeric object type (e.g., Integer, Double, or any class that extends


Write a generic class, MyMathClass, with a type parameter T where T is a numeric object type (e.g., Integer, Double, or any class that extends java.lang. Number). Add a method named standardDeviation that takes an ArrayListof type T and returns as a double the average of the values in the ArrayList. Use the doubleValue0 method in the Number class to retrieve the value of each number as a double. Test your method with suitable data. Your program should generate a compile-time error if your standard deviation method is invoked on an ArrayList that is defined for nonnumeric elements (e.g., Strings) You can use the following sample code to start. Notice how the average method is working and try to implement a generic standard deviation method. The rule for standard deviation is: class MyMathClass
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
