Why Is String Formatting Causing a Casting Exception?

北战南征 提交于 2020-01-03 15:56:15

问题


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?


回答1:


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));

but without the varargs support. I suspect you want:

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

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



来源:https://stackoverflow.com/questions/7643151/why-is-string-formatting-causing-a-casting-exception

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!