Java – ClassCastException
ClassCastException: Thrown when an invalid cast is attempted between incompatible types.
Example:
Object obj = "Hello World";
try {
Integer i = (Integer) obj;
} catch (ClassCastException e) {
System.out.println("Caught ClassCastException: " + e.getMessage());
}
No images available.