I am trying to typecast and object to get at methods specific to its class, but am running into a strange error at runtime.
The line that causes the problem is simply:
whoops2 temp=(whoops2 ) teammate;
where teammate is declared as class which whoops2 extends, and is actually a whoops2 object. The error I'm receiving is:
java.lang.Class CastException: whoops2 cannot be cast to whoops2
java.lang.Class CastException: whoops2 cannot be cast to whoops2
at whoops2.takeTur n(whoops2.java: 92)
I've never run into a problem like this typecasting before. I feel like there must be something stupid I'm missing, but for the life of me I can't figure what. Any help would be greatly appreciated.
Thank you
The line that causes the problem is simply:
whoops2 temp=(whoops2 ) teammate;
where teammate is declared as class which whoops2 extends, and is actually a whoops2 object. The error I'm receiving is:
java.lang.Class CastException: whoops2 cannot be cast to whoops2
java.lang.Class CastException: whoops2 cannot be cast to whoops2
at whoops2.takeTur n(whoops2.java: 92)
I've never run into a problem like this typecasting before. I feel like there must be something stupid I'm missing, but for the life of me I can't figure what. Any help would be greatly appreciated.
Thank you
Comment