Number holder

Report a typo

There is a Holder class that accepts all kinds of parameters. Correct the code to make the class accept only Number class and all of its descendants as parameters.

Note, that both Integer and Double (as well as some other wrapper classes like Float, Long, etc.) are subclasses of an abstract class Number.

Write a program in Java 17
class Holder<T> {
private T value;

public void setValue(T value) {
this.value = value;
}

public T getValue() {
return value;
}
}
___

Create a free account to access the full topic