If the Java method accepts a variable arguments (varargs) parameter and we want to invoke the method from Clojure we must pass an array as argument. To create an array in Clojure we can use several functions.

For primitive type arrays we can use for example int-array to get a int[] array.

Once we have the array we can use it as argument value for the varargs parameter of the Java method we want to invoke. In the following example we use into-array, to-array and short-array to invoke a Java method with varargs parameter and see how we can build different array types: Written with Clojure 1.10.1.

Related Articles