MATLAB: Does the Hashtable with string keys not work as expected in MATLAB

hashmapjava.lang.objectkeymapMATLABtable

I have the following code in Java:
Hashtable hash =new Hashtable();
hash.put("a", "aa");
hash.put("b", "bb");
I then pass that object back to MATLAB and try to access those elements in the Hashtable:
hash
a=hash.get('a')
b=hash.get('b')
hash.put('d','dddddd');

Best Answer

This is due to how MATLAB converts the strings to Java Objects.
The workaround is to explicitly convert the MATLAB strings to the java.lang.String class.