interface IBase {
void doJob();
}
public class MyCache<T extends IBase> {
private T t1;
private T t2;
public MyCache(T t1, T t2) {
this.t1 = t1;
this.t2 = t2;
}
@PostConstruct
private void init() {
t1.update();
t2 = t1.clone(); // ERROR!
}
}
As you see, I'm trying to develop a generic class. In the function init()
, I assign the copy of t1
to t2
. But it can't be compiled.
I'm not very good at Java. Can someone help me on this issue?