Possible Duplicate:
Why we can't do List<Parent> mylist = ArrayList<child>();
I've a question on polymorphism and invoking methods.
My service layer signature is public void saveRules(String paramOne, String paramTwo, List<RuleDTO> rules)
My EvaluationRuleDTO extends from RuleDTO
So from my controller I attempt to perform the following:
service.saveRules(String paramOne, String paramTwo, List<EvaluationRuleDTO> rules)
.
But this is not allowed as it complains about List<EvaluationRuleDTO
> rules not being List<RuleDTO> rules
.
This does not make much sense to me. Is this a weakness in the Java language, or what concept am I missing here?
Thanks