📜  java代码示例中的classcastexception

📅  最后修改于: 2022-03-11 14:52:39.083000             🧑  作者: Mango

代码示例1
Object someStringAsObject="Hello";
String asString=(String)someStringAsObject;//works
Integer asInteger=(Integer)someStringAsObject;//throws ClassCastException because it is a String and not an Integer