User`s manual
Handling Data Returned from a Java Method
5-57
Built-In Data Types
Java built-in data types are described in “Passing Built-In Data Types” on
page 5-48. Basically, this data type includes
boolean, byte, short, long, int,
double, float, and char. When the value returned from a method call is one of
these Java built-in types, MATLAB converts it according to the table,
“Conversion of Java Types to MATLAB Types” on page 5-56.
A single numeric or
boolean value converts to a 1-by-1 matrix of double, which
is convenient for use in MATLAB. An array of a numeric or
boolean return
values converts to an array of the closest base type, to minimize the required
storage space. Array conversions are listed in the right-hand column of the
table.
A return value of Java type
char converts to a 1-by-1 matrix of char. And an
array of Java
char converts to a MATLAB array of that type.
Java Objects
When a method call returns Java objects, MATLAB leaves them in their
original form. They remain as Java objects so you can continue to use them to
interact with other Java methods.
The only exception to this is when the method returns data of type,
java.lang.Object. This class is the root of the Java class hierarchy and is
frequently used as a catchall for objects and arrays of various types. When the
method being called returns a value of the
Object class, MATLAB converts its
value according to the table, “Conversion of Java Types to MATLAB Types” on
page 5-56. That is, numeric and
boolean objects such as java.lang.Integer or
java.lang.Boolean convert to a 1-by-1 MATLAB matrix of double. Object
arrays of these types convert to the MATLAB data types listed in the
right-hand column of the table. Other object types are not converted.
Converting Objects to MATLAB Data Types
With the exception of objects of class String and class Object, MATLAB does
not convert Java objects returned from method calls to a native MATLAB data
type. If you want to convert Java object data to a form more readily usable in
MATLAB, there are a few MATLAB functions that enable you to do this. These
are described in the following sections.