Why does string formatting throw a cast exception?

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

+4
source share
1 answer

I do not know Clojure, but I suspect that I am trying to call a method as if it were Java:

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

but without 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 really know Clojure :)

+7
source

All Articles