Explanation of “ClassCastException” in Java

前端 未结 12 1694
小蘑菇
小蘑菇 2020-11-21 11:12

I read some articles written on \"ClassCastException\", but I couldn\'t get a good idea on that. Is there a good article or what would be a brief explanation?

12条回答
  •  猫巷女王i
    2020-11-21 11:51

    Exception is not a subclass of RuntimeException -> ClassCastException

        final Object  exception = new Exception();
        final Exception data = (RuntimeException)exception ;
        System.out.println(data);
    

提交回复
热议问题