小编Adn*_*tti的帖子

从String转换为Object时出现ClassCastException ..为什么?

我只是在玩MessageFormat但是当我尝试将String传递给MessageFormat 格式时,它编译得很好,但后来我得到了一个运行时的classcast异常.这是代码.

MessageFormat format = new MessageFormat(""); Object obj = Integer.toHexString(10); format.format(obj);

现在我得到的运行时异常如下.

线程"main"中的异常java.lang.ClassCastException:java.lang.String无法强制转换为[Ljava.lang.Object; at java.text.MessageFormat.format(Unknown Source)at java.text.Format.format(Unknown Source)at JavaCore2.Codepoint.main(Codepoint.java:21)

casting exception classcastexception

7
推荐指数
1
解决办法
1896
查看次数

标签 统计

casting ×1

classcastexception ×1

exception ×1