make-array

added
1.0

ns
clojure.core

type
function

(make-array type len) (make-array type dim & more-dims)

Creates and returns an array of instances of the specified class of
the specified dimension(s).  Note that a class object is required.
Class objects can be obtained by using their imported or
fully-qualified name.  Class objects for the primitive types can be
obtained using, e.g., Integer/TYPE.

                (make-array Integer/TYPE 3)

; Types are defined in clojure/genclass.clj:
;    Boolean/TYPE
;    Character/TYPE
;    Byte/TYPE
;    Short/TYPE
;    Integer/TYPE
;    Long/TYPE
;    Float/TYPE
;    Double/TYPE
;    Void/TYPE
            
                user=> (pprint (make-array Double/TYPE 3))
[0.0, 0.0, 0.0]

user=> (pprint (make-array Integer/TYPE 2 3))
[[0, 0, 0], [0, 0, 0]]


;; Create an array of Threads, then show content and type
user=> (def ar (make-array Thread 3))
#'user/ar

user=> (pprint ar)
[nil, nil, nil]

user=> (type ar)
[Ljava.lang.Thread;