B
ba.hons
Hello,
i wonder if anyone can help or advise me on why am getting a ClassCast
Exception
I have a class called A (for instance) which implements another class
(B)
I have also created a new class called C which implements A
Now i have a method that i can not control which returns an instance of
A, but i need to convert this instance when it is returned to my new
type C which just has an extra method.
I cant just add the extra method to class A as i cant modify this code.
i tried to cast A to C like this
C test = (C)objectOfTypeA;
and then i get a classcast exception?
Anyone any ideas?
Thanks
Adam
i wonder if anyone can help or advise me on why am getting a ClassCast
Exception
I have a class called A (for instance) which implements another class
(B)
I have also created a new class called C which implements A
Now i have a method that i can not control which returns an instance of
A, but i need to convert this instance when it is returned to my new
type C which just has an extra method.
I cant just add the extra method to class A as i cant modify this code.
i tried to cast A to C like this
C test = (C)objectOfTypeA;
and then i get a classcast exception?
Anyone any ideas?
Thanks
Adam