For example I have a Processor base class with a method that returns an Object and takes Object as a parameter. I want to extend it and create a StringProcessor which will return String and take String as parameter. However covariant typing is only allowed with return value, but not parameter. What is the reason for such limitations?
class Processor {
Object process (Object input) {
//create a copy of input, modify it and return it
return copy;
}
}
class StringProcessor extends Processor {
@Override
String process (String input) { // permitted for parameter. why?
//create a copy of input string, modify it and return it
return copy;
}
}