User`s manual
5 Calling Java from MATLAB
5-26
If you use which -all for the method equals, with the String and
java.awt.Frame classes loaded, you see the following display.
which -all equals
java.lang.String.equals % String method
java.awt.Frame.equals % Frame method
com.mathworks.ide.desktop.MLDesktop.equals % MLDesktop method
The which function operates differently on Java classes than it does on
MATLAB classes. MATLAB classes are always displayed by
which, whether or
not they are loaded. This is not true for Java classes. You can find out which
Java classes are currently loaded by using the command
[m,x,j]=inmem,
described in “Determining Which Classes Are Loaded” on page 5-8.
For a description of how Java classes are loaded, see “Making Java Classes
Available to MATLAB” on page 5-6.
Java Methods That Affect MATLAB Commands
MATLAB commands that operate on Java objects and arrays make use of the
methods that are implemented within, or inherited by, these objects’ classes.
There are some MATLAB commands that you can alter somewhat in behavior
by changing the Java methods that they rely on.
Changing the Effect of disp and display
You can use the disp function to display the value of a variable or an
expression in MATLAB. Terminating a command line without a semicolon also
calls the
disp function. You can also use disp to display a Java object in
MATLAB.
When
disp operates on a Java object, MATLAB formats the output using the
toString method of the class to which the object belongs. If the class does not
implement this method, then an inherited
toString method is used. If no
intermediate ancestor classes define this method, it uses the
toString method
defined by the
java.lang.Object class. You can override inherited toString
methods in classes that you create by implementing such a method within your
class definition. In this way, you can change the way MATLAB displays
information regarding the objects of the class.