2类型转换异常:Exception in thread "main" java.lang.ClassCastException:java.lang.Object cannot be
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了2类型转换异常:Exception in thread "main" java.lang.ClassCastException:java.lang.Object cannot be相关的知识,希望对你有一定的参考价值。
public class TestException {
public static void main(String[] args) {
Object obj = new Integer(1);
int i =(Integer)(obj);
System.out.println(i);
Object object = new Object();
if (object instanceof Integer){
System.out.println(true);
}
int j = (Integer)object;
System.out.println(j);
}
}
1 Exception in thread "main" java.lang.ClassCastException: java.lang.Object cannot be cast to java.lang.Integer at TestException.main(TestException.java:8)
以上是关于2类型转换异常:Exception in thread "main" java.lang.ClassCastException:java.lang.Object cannot be的主要内容,如果未能解决你的问题,请参考以下文章
Exception in thread "com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2"异常解决(
(转)Exception in thread "main" java.lang.NullPointerException java报空指针异常