According to the documentation:
Thrown to indicate that the code has attempted to cast an Object
to a subclass
of which it is not an instance. For example, the following code generates a ClassCastException
:
Object x = new Integer(0);
System.out.println((String)x);
More Related Contents:
- Call a method with parameters in java
- How do I correctly implement this code segment without getting a logic error? [closed]
- How to use the toString method in Java?
- Concatenating null strings in Java [duplicate]
- Spring RestTemplate – how to enable full debugging/logging of requests/responses?
- POSTing a @OneToMany sub-resource association in Spring Data REST
- Convert String to Calendar Object in Java
- Why doesn’t a missing annotation cause a ClassNotFoundException at runtime?
- Last row always removed from DefaultTableModel, regardless of index
- Why does this subtraction not equal zero?
- Add multiple items to an already initialized arraylist in Java
- sending variable from one jsp to another jsp
- Curly braces in “new” expression? (e.g. “new MyClass() { … }”)
- Why does dividing a float by an integer return 0.0?
- Get method arguments using Spring AOP?
- Return data from AsyncTask class
- AssertEquals 2 Lists ignore order
- java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex in Android Studio 3.0 [closed]
- Accessing a mapper’s counter from a reducer
- Deallocating Direct Buffer Native Memory in Java for JOGL
- How can I create an executable/runnable JAR with dependencies using Maven?
- In Java Lambda’s why is getClass() called on a captured variable
- Java Enums, JPA and Postgres enums – How do I make them work together?
- How to define a JUnit method rule in a test suite?
- Maven build failed: “Unable to locate the Javac Compiler in: jre or jdk issue”
- Is it possible to use sun.misc.Unsafe to call C functions without JNI?
- How to get the enum type by its attribute?
- How to merge two ArrayLists without duplicates? [duplicate]
- JavaFX – setOnAction not applicable
- Example of O(n!)?