Main Content

javaArray

ConstructJavaarray object

Description

example

ObjArr= javaArray(PackageName.ClassName,x1,...,xN)constructs an emptyJava®array objectfor objects of the specifiedPackageName.ClassNameclass. The array created byjavaArrayis equivalent to the array created by the following Java code.

A = new PackageName.ClassName[x1]...[xN];

Examples

collapse all

Create 4-by-5 array ofjava.lang.Doubletype.

x1 = 4; x2 = 5; dblArray = javaArray('java.lang.Double',x1,x2);

Fill in values.

form = 1:x1forn = 1:x2 dblArray(m,n) = java.lang.Double((m*10) + n);endend

Display results.

dblArray
dblArray = java.lang.Double[][]: [11] [12] [13] [14] [15] [21] [22] [23] [24] [25] [31] [32] [33] [34] [35] [41] [42] [43] [44] [45]

Input Arguments

collapse all

Name of the Java class, including the package name, specified as a string or character vector.

Data Types:char

Dimensions of the array, specified as an integer. If any argument is zero,javaArraycreates a zero-length Java array with the specified number of dimensions. A zero-length Java array is not the same as an empty MATLAB®array, which is converted to a Javanullwhen passed to a Java method.

Data Types:double

Output Arguments

collapse all

Java array with dimensionsx1,...,xN.

More About

collapse all

JavaArray Object

A Java array object is an object with Java dimensionality. For more information, seeHow MATLAB Represents Java Arrays.

Tips

版本历史

Introduced before R2006a