ragi singh wrote:
My question is , Java allows downcasting then why is my code failing to compile ?
You have misunderstood the down casting. Clue: Down casting for reference variable, not to objects. If you allowed to cast object, then what will be the real logic? You can't cast a object to any other object!
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
You are Welcome. If we are allowed to cast a object into another, then there is no point of talking polymorphism and other stuff in Java! I think, now you got what does mean by down casting and up casting!