I have some MATLAB code and some Java code that need to talk with each other. I was getting a NoSuchMethodError
. When I pass a MATLAB double array to a Java method that accepts double[]
argument.
So I write a simple "hello world" to get the class of an object passed to the method
public void printArray(Object array) {
System.out.println(array.getClass());
System.out.println(array.getClass().getPackage());
}
Calling this method from MATLAB, I get this interesting output:
>> a.printArray(2)
class java.lang.Double
package java.lang
>> a.printArray('hello')
class java.lang.String
package java.lang
>> a.printArray(true)
class java.lang.Boolean
package java.lang
>> a.printArray([2 3 4])
class [D
null
>> a.printArray([true false])
class [Z
null
Can someone explain whats happening. I have MATLAB R14 and the Java class is compiled with 1.3 compatibility.