This week's book giveaway is in the Java in General forum. We're giving away four copies of Helidon Revealed: A Practical Guide to Oracle’s Microservices Framework and have Michael Redlich on-line! See this thread for details.
here as method say() is overrided,so object type determines which method will invoked,so as child method is non generic it can hold anything(i.e. not primitive).
this code gives compiler error, why so?
Also if we put at line 16 it invokes child class say() method.
output:child
And for the output as child, generics only for compiler! Do you got the point, why do these methods override even though the differ the method signature?
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
but as overriding is happening, so it should consider the non-generic method which can take anything
but why it is considering generic method here of parent class just because of parent reference type?
but finally it invokes child method if we use line below
When compile time, it check the reference type, and at the time, generics also there. But at runtime, the generic and non-generic versions are same, VMI is there! {Generics only for compiler}
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
Abimaran Kugathasan wrote:When compile time, it check the reference type, and at the time, generics also there. But at runtime, the generic and non-generic versions are same, VMI is there! {Generics only for compiler}
thanks, it is more clear now.
wonderful explanation