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 ArrayList of type T and returns as a double the standard deviation of the values in the ArrayList. Use the doubleValue() method in the Number class to retrieve the value of each number as a double.
The standard deviation of a list of numbers is a measure of how much the numbers deviate from the average. If the standard deviation is small, the numbers are clus-tered close to the average. If the standard deviation is large, the numbers are scat-tered far from the average. The standard deviation of a list of numbers n1, n2, n3, and so forth is defined as the square root of the average of the following numbers: (n1 - a)2, (n2 - a)2, (n3 - a)2, and so forth. The number a is the average of the numbers n1, n2, n3, and so forth.
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)
Question is about Java.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
