Why is the property definition of LifeCycle not enough, why does my constructor need to also define it as an ArrayList()? Even so, why doesn’t my ArrayList inherit the limitation of <LifeCycle> from the property definition? I don’t like having to set it in both places, seems very redundant.
class Search {
private Collection<LifeCycle> lifeCycleCollection;
public Search() {
this.lifeCycleCollection = new ArrayList<LifeCycle>();
}
...
Collection is an interface, when you create the instance you are actually specifying the implementation.
As to your question about Generics, as with Java 7 you can also write