String[] stringArray = new String[mHashMap.keySet().size()];
int i = 0;
for(String key: mHashMap.keySet()){
stringArray[i] = mHashMap.get(key);
i++;
}
我在上面显示的for循环,另一个也评论如下:
for(String key : mHashMap.keySet()){
//do this
}
"for all keyStrings in myHashMap.keyStringSet(), do this"
eg. for each item in the hashmap, do whatever is in the brackets.
2 回答
试试这个 :
到字符串数组:
创建一个与hashmap相同大小的新字符串数组 . 循环遍历您的hashmap并将每次迭代分配给数组中的元素 .
我在上面显示的for循环,另一个也评论如下:
你的字符串数组已经完成 .