If either of the above rules are violated, then a ClassCastException is thrown by the class loader.
如果违反了以上任何一条规则,那么类装入器就会抛出ClassCastException。
How are we supposed to diagnose a bug like this one when the only error signaled is a ClassCastException in code that makes no use of casts?
当未使用数据类型转换的代码中显示的唯一错误就是ClassCastException时,我们应如何诊断这样的错误?
ClassCastException - if the specified object's type prevents it from being compared to this object.
如果指定的对象类型不允许它和该对象进行比较时抛出。
ClassCastException - if the type of the specified element is incompatible with this collection (optional).
如果指定元素的类型与集合不相容时抛出(可选)。
ClassCastException - if the class of an element of the specified collection prevents it from being added to this collection.
如果指定集合的某个元素类型阻止其加入集合时抛出。
ClassCastException - if the types of one or more elements in the specified collection are incompatible with this collection (optional).
如果指定集合的一个或多个元素的类型与集合不相容时抛出(可选)。
ClassCastException - if the types of one or more elements in the specified collection are incompatible with this collection (optional).
如果指定集合的一个或多个元素的类型与集合不相容时抛出(可选)。
应用推荐