I was trying to write some code that looked like this:
public List<IObject> getObject(){
ArrayList<ConcreteObject> objects = new ArrayList<ConcreteObject>();
return objects;
}
(Where ConcreteObject implements IObject)
This doesn't work at all. It gives a compiler error. Does Java have plans to support this in the future? What is the best workaround until then? What I ended up doing was:
public List<IObject> getObject(){
List<IObject> objects = new ArrayList<IObject>();
return objects;
}
This works and maybe there aren't really any bad side effects of doing it this way. Is this the generally accepted best approach?