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

 채택된 답변

MathWorks Support Team
MathWorks Support Team 2009년 6월 27일

0 개 추천

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