+ 1
Java help
Classcastexception??? why do i get Classcastexception error for this?could someone explain please... https://code.sololearn.com/cWnu3boE0x0T/?ref=app
1 Odpowiedź
+ 3
CHANGE:
Pokemon p1=new Pokemon();
((Pikachu)p1).sound();
TO:
Pokemon p1 = new Pokemon();
p1.sound();
^p1 is already of the Pokemon class type, so you don't need to cast it. That'll fix your problem.