my code is like this:
i have two classes
first class:
public class Box<E> {
E data1;
public Box(E data) {
this.data1 = data;
}
public E getData() {
return data1;
}
}
second class:
public class IntBox extends Box<Integer>{
Integer data;
public IntBox(Integer data) {
this.data = data;
}
public Integer getData() {
return data;
}
}
why doesn’t this class extend from Box<E>?
That won’t compile.
Your second class should be:
And then it will properly extend it and use Box’s methods.