如何根据元素的位置从HashMap中检索元素,可能吗
使用LinkedHashMap,当需要按位置检索时,将值转换为ArrayList
LinkedHashMap<;字符串,字符串>;linkedHashMap=新linkedHashMap<;字符串,字符串>;();
/*填充*/
linkedHashMap.put(“key0”、“value0”);
linkedHashMap.put(“键1”、“值1”);
linkedHashMap.put(“键2”、“值2”);
/*通过位置*/
int pos=1;
字符串值=(新建ArrayList<;String>;(linkedHashMap.values()).get(pos);