P
Pradeep Kumar
Hi all ......
suppose a code ..
interface one {
Object methodOne();
}
class two implements one {
public String methodOne() {
return "";
}
}
now as i implmented a interface "one" in class "two".. i changed the return
type to a subclass of Object "String".. this is perfectlly valid in term of
logic or concept... but java compiler is giving an error ... compiler says
that prototype is not same .. this is fine ...
now my question is why java compiler make such type of restriction ... i
think there is no problem in declaring return type as any subclass ...
any suggestion / answer / hint ?????????????
suppose a code ..
interface one {
Object methodOne();
}
class two implements one {
public String methodOne() {
return "";
}
}
now as i implmented a interface "one" in class "two".. i changed the return
type to a subclass of Object "String".. this is perfectlly valid in term of
logic or concept... but java compiler is giving an error ... compiler says
that prototype is not same .. this is fine ...
now my question is why java compiler make such type of restriction ... i
think there is no problem in declaring return type as any subclass ...
any suggestion / answer / hint ?????????????