
what is the ClassCastException and exp?

ClassCastException occurs, when you try to assign a reference variable of a class to an incompatible reference variable of another class.
Example
import java.util.Vector;
public class CastException {
public static void main(String[] args) {
Vector v = new Vector();
int i = 10;
Object obj = v.add(i);
try {
String y = (String)obj;
v.add(y);
} catch (ClassCastException e) {
System.out.println("Class is really: " + obj.getClass().getName());
e.printStackTrace();
}
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.