Why does my Hashtable with string keys not work as expected in MATLAB?

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');

 采纳的回答

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.

更多回答(0 个)

类别

在 帮助中心 和 File Exchange 中查找有关 Deploy to Java Applications Using MWArray Data API 的更多信息

产品

版本

R2008a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by