为什么字符串格式化导致铸造异常? [英] Why Is String Formatting Causing a Casting Exception?

查看:79
本文介绍了为什么字符串格式化导致铸造异常?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么(String / format%8s(Integer / toBinaryString 6))导致一个 java.lang.ClassCastException:java。 lang.String不能转换为[Ljava.lang.Object 投射异常?

Why does (String/format "%8s" (Integer/toBinaryString 6)) result in a java.lang.ClassCastException: java.lang.String cannot be cast to [Ljava.lang.Object casting exception?

推荐答案

不知道Clojure,但我怀疑试图调用该方法,就像它是Java:

I don't know Clojure, but I suspect that's trying to call the method as if it were the Java:

String.format("%8s", Integer.toBinaryString(6));

,但不支持 varargs。 I 可疑:您想要的:

but without the varargs support. I suspect you want:

(String/format "%8s" (into-array Object (Integer/toBinaryString 6)))

请参阅这个邮件列表线程获取更多信息从谁实际上知道Clojure:)

See this mailing list thread for more information from people who actually do know Clojure :)

这篇关于为什么字符串格式化导致铸造异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆