Main Content

Java Methods With Optional Input Arguments

To call a Java® method that accepts multiple optional input arguments, create a Java array in MATLAB®. For example, MyClass has a method with this signature:

public int myMethod(Integer... numbers)

To pass a scalar value 4 of type java.lang.Integer, create a variable numbers using javaArray.

numbers = javaArray('java.lang.Integer', 1);

Create oneNumber with value 4 and assign it to the Java array.

oneNumber = java.lang.Integer(4);
numbers(1) = oneNumber;

Call myMethod.

myObj = MyClass;

See Also