Java COde
Modify the GenericMath<T> class to:
Create a new method named printAdd which accepts aparameter of type T. Add this value to the existingnumber stored in the value field and print theresult.
You do not need to update the stored value, just print theresult
It is OK to treat numbers as floating-point values
public class GenericMath<T extends Number> {
private T value;
public GenericMath(T value) {
this.value = value;
}
public T getValue() {
return this.value;
}
public void setValue(T value) {
this.value = value;
}
public void printValue() {
System.out.println(this.value);
}
}
Java COde Modify the GenericMath class to: Create a new method named printAdd which accepts a parameter of type T. Ad
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am