Skip to Main Content Skip to Search
Product Documentation

javaMethod - Invoke Sun Java method

Syntax

javaMethod(MethodName, ClassName, x1, ..., xn)
javaMethod(MethodName, JavaObj, x1, ..., xn)

Description

javaMethod(MethodName, ClassName, x1, ..., xn) calls the static method MethodName in the class ClassName with the signature matching the arguments x1, ..., xn. MethodName and ClassName are strings.

javaMethod(MethodName, JavaObj, x1, ..., xn) calls the nonstatic method MethodName on the Java object array JavaObj.

Tips

Use the javaMethod function to:

The javaMethod function enables you to use methods having names longer than 31 characters. This is the only way you can invoke such a method in the MATLAB software. For example:

javaMethod('DataDefinitionAndDataManipulationTransactions', T);

With javaMethod, you can also specify the method to be invoked at run-time. In this situation, your code calls javaMethod with a string variable in place of the method name argument. When you use javaMethod to invoke a static method, you can also use a string variable in place of the class name argument.

Examples

To invoke the static Java method isNaN on class java.lang.Double type:

javaMethod('isNaN','java.lang.Double',2.2)

The following example invokes the nonstatic method setMonth, where myDate is a java.util.Date object.

myDate = java.util.Date;
javaMethod('setMonth', myDate, 3);

See Also

import | isjava | javaArray | javaMethodEDT | javaObject | methods

  


» Learn more
» Download free kit
» Get trial software

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS