In: Computer Science
Write a small Java class called StoreAddStuff that uses generics to store two variables of type T passed in during construction, then returns their sum through a non-static method.
class StoreAddStuff<T extends Number>{
        T x;
        T y;
        
        public StoreAddStuff(T aX, T aY) {
                super();
                x = aX;
                y = aY;
        }
        public <T extends Number> double sum() {
                return x.doubleValue()+y.doubleValue();
        }
}
public class TestStoreAddStuff {
        public static void main(String[] args) {
                StoreAddStuff<Integer>a =new StoreAddStuff<Integer>(10,3);
                System.out.println(a.sum());
        }
}

NOTE : PLEASE COMMENT BELOW IF YOU HAVE CONCERNS.
I AM HERE TO HELP YOUIF YOU LIKE MY ANSWER PLEASE RATE AND HELP ME IT IS VERY IMP FOR ME