Also you can substitute #^"[C" with the more legible #^chars.
On Oct 28, 7:27 pm, Alex Osborne <a...@meshy.org> wrote: > Chick Corea wrote: > > What is wrong with this code? I want to instantiate a Java String > > from a Java character-array. > > But I want it to be fast, hence the need to cast per the "warn on > > reflection" message. > > > user=> (set! *warn-on-reflection* true) > > true > > user=> (new String #^"[C" (make-array Character/TYPE 3 \a )) > > java.lang.ClassCastException: [[C cannot be cast to [C > > (NO_SOURCE_FILE:0) > > Note the exception, "[[C" means a two-dimensional arary. (make-array > Character/TYPE 3 \a) actually means (make-array Character/TYPE 3 97) so > a 3 by 97 two-dimensional array (new char[3][97] in java syntax). What > you probably want is: > > user> (String. #^"[C" (into-array Character/TYPE (repeat 3 \a))) > "aaa" --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---