javaMethod - Invoke Sun Java method

Syntax

javaMethod('MethodName','ClassName',x1,...,xn)
javaMethod('MethodName',J,x1,...,xn)

Description

javaMethod('MethodName','ClassName',x1,...,xn) invokes the static method MethodName in the class ClassName, with the argument list x1,...,xn.

javaMethod('MethodName',J,x1,...,xn) invokes the nonstatic method MethodName on the object J, with the argument list x1,...,xn.

Remarks

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

javaArray, javaObject, import, methods, isjava

  


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