ClojureDocs

Nav

Namespaces

Instantiate a class. See http://clojure.org/java_interop#new for
more information.
2 Examples
;; Create a Java ArrayList using the 0 argument constructor
user=> (def a  (new java.util.ArrayList))
#'user/a
user=> (.add a "aaa")
true
user=> (.add a "bbb")
true
user=> a
#<ArrayList [aaa, bbb]>
;; Create another ArrayList and add integers using the doto macro
user=> (def ai (doto (new java.util.ArrayList) (.add 1) (.add 2) (.add 0)))
#'user/ai
user=> ai
#<ArrayList [1, 2, 0]>
See Also

The '.' special form is the basis for access to Java. It can be considered a member-access operator,...

Added by AtKaaZ
0 Notes
No notes for new