Reassigning a generic Java variable
I'm slightly confused why the following does not compile:
public <E extends Object> E doSomething() {
return new Object();
}
I've researched the problem a little and found various fixes like casting
to an (E) or using Class Literals but I'm still unsure what is actually
wrong with the above.
No comments:
Post a Comment