I have something like
public void setCustomHandler(final List<ClassA> customHandler) {
this.customHandler = customHandler;
}
Now I create a classB and call setCustomHandler(List<B>). Eclipse is telling me to create
setCustomHandler(final List<ClassB> customHandler){
}
How can I just assign
List<ClassB objects> to List<ClassA objects>?
Short answer: You can’t.
List<ClassB>is not a subtype ofList<ClassA>(even ifClassBis a subtype ofClassA):If you have the control of the receiving class, you could perhaps let it accept
List<? extends ClassA>instead: