What is ClassCastException

J

James McGill

When I run the java code using swings i got
java.lang.ClassCastException? Why ?

Without seeing your code, it's not possible to know exactly. Also, to
answer, it's important to know how familiar you are with Java
compile-time and runtime types, and casting.
 
B

Bart Cremers

This means that somewhere in your code your try to cast an object to a
type to which the object can not be casted.

Object o = new Integer(0);
Integer i = (Integer) o; // Working cast
String s = (String) o; // ClassCastException

Regards,

Bart
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top