Explanation of ClassCastException in Java

Straight from the API Specifications for the ClassCastException: Thrown to indicate that the code has attempted to cast an object to a subclass of which it is not an instance. So, for example, when one tries to cast an Integer to a String, String is not an subclass of Integer, so a ClassCastException will be thrown.