javaArray Search Help Documentation Toggle navigation Documentation Home MATLAB Examples Functions Release Notes PDF Documentation Advanced Software Development Calling External Functions Call Java Libraries MATLAB Functions javaArray On this page Syntax Description Examples Create 4-By-5 Java Array Input Arguments PackageName.ClassName x1,...,xN Output Arguments ObjArr More About Java Array Object Tips See Also javaArray Construct Java array object collapse all in page 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. The array created by javaArray is equivalent to the array created by the Java code A = new PackageName.ClassName[x1]...[xN]; Examples collapse all Create 4-By-5 Java Array Open Script 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 collapse all PackageName.ClassName — Name of Java class character vector Name of the Java class, including the package name, specified as a character vector. Data Types: char x1,...,xN — Dimensions of the array integer Dimensions of the array, specified as an integer. If any argument is zero, javaArray creates 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 Java null when passed to a Java method. Data Types: double Output Arguments collapse all ObjArr — Java array Java array Java array with dimensions x1,...,xN. More About collapse all Java Array Object A Java array object is an object with Java dimensionality. Tips 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. Java Arrays See Also class | isjava | javaMethodEDT | javaObjectEDT | methodsview Introduced before R2006a Was this topic helpful? MATLAB Documentation Examples Functions Release Notes PDF Documentation Other Documentation Simulink Symbolic Math Toolbox Statistics and Machine Learning Toolbox Image Processing Toolbox Signal Processing Toolbox Documentation Home Support MATLAB Answers Installation Help Bug Reports Product Requirements Software Downloads © 1994-2016 The MathWorks, Inc. Terms of Use Patents Trademarks Acknowledgments