Documentation Center

  • Trials
  • Product Updates

javaArray

Construct Java array object

Syntax

  • ObjArr = javaArray(PackageName.ClassName,x1,...,xN) example

Description

example

ObjArr = javaArray(PackageName.ClassName,x1,...,xN) constructs an empty Java® array object for objects of the specified PackageName.ClassName class.

Examples

expand all

Create 4-By-5 Array

Create 4-by-5 array of java.lang.Double type.

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

Fill in values.

for m = 1:x1
    for n = 1:x2
        dblArray(m,n) = java.lang.Double((m*10) + n);
    end
end

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

expand all

PackageName.ClassName — Name of Java classstring

Name of Java class, including package name, specified as a string.

Data Types: char

x1,...,xN — Dimensions of the arrayinteger

Dimensions of the array, specified as integer.

Data Types: double

Output Arguments

expand all

ObjArr — Java arrayJava array

Java array with dimensions x1,...,xN.

More About

expand all

Java Array Object

A Java array object is an object with Java dimensionality.

Tips

  • The array created by javaArray is equivalent to the array created by the following Java code:

    A = new PackageName.ClassName[x1]...[xN];
    
  • To create an array of primitive Java types, create an array of the equivalent MATLAB® type, shown in the Conversion of MATLAB Types to Java Types table. See Conversion of MATLAB Argument Data.

See Also

| | | |

Was this topic helpful?