Look carefully at the ClassCastException. It tells you the line numbers in the file which are generating the exception. What is the first line in the stack trace? Which part of the program does it refer to?
"I'm not back." - Bill Harding, Twister
Joined: Dec 31, 2004
You receive a ClassCastException because you are trying to cast a Object to a "My" object reference.
Remember, you can do upcasting implicitly. That is to say, you can assign any object of a subclass to an object of its parent class. The contrary is not always true.
You can do downcasting explicitly by means of the cast operator, however the object has to be assignable to the reference variable receiving the casted reference.
By assignable I mean this casted object has to be of the same class or a subclass of the variable receiving the casted reference.