Complete the code to implement a generic class that only acc…
Complete the code to implement a generic class that only accepts objects of types that extend the Number class. You need to: Implement a generic class that accepts only types that are subclasses of Number (such as Integer, Double). Add a method to calculate the average of the two stored values. In the main method, initialize the class with two Integer values and two Double values, and print the average of each pair. // Create a generics class with bounded typesclass GenericsClass { // Variables to hold the data private ___ data1; private ___ data2; // Constructor to initialize both data values public GenericsClass(___ data1, ___ data2) { this.data1 = data1; this.data2 = data2; } // Method to calculate the average of the two stored values public double average() { }} class Main { public static void main(String[] args) { // Initialize the generic class with two Integer values and print the average // Initialize the generic class with two Double values and print the average }}
Read Details