Main Content

Determine What Classes Define a Method

To display the fully qualified name of a method implemented by a loaded Java® class, call the which function. To find all classes that define the specified method, use which with the -all qualifier.

For example, to find the package and class name for the concat method, type:

which concat

If the java.lang.String class is loaded, MATLAB® displays:

concat is a Java method  % java.lang.String method

If the String class has not been loaded, MATLAB displays:

concat not found.

Suppose that you loaded the Java String and java.awt.Frame classes. Both of these classes have an equals method. Type:

which -all equals

The MATLAB display includes entries like these:

equals is a Java method      % java.lang.String method
equals is a Java method      % java.awt.Frame.equals
equals is a Java method      % com.mathworks.jmi.MatlabPath method

The which function operates differently on Java classes than it does on MATLAB classes:

  • which always displays MATLAB classes, whether they are loaded

  • which only displays Java classes that are loaded

You can find out which Java classes are currently loaded by using the command [m,x,j]=inmem.

See Also

|

Related Topics