I created a Map<Integer, ArrayList<String>> map
and I would like to compare each value in map with one ArrayList<String> likeList
and get key if they match. I will bring the key to use later.
我试图像这样运行我的代码,但是它不起作用,因为它什么也不返回:
for (int key : map.keySet()) {
if(map.get(key).equals(likeList)){
index = key;
Log.d("IndexN", String.valueOf(index));
}
}
然后,我尝试了这个:
int index = 0;
for (Map.Entry<Integer, ArrayList<String>> entry : map.entrySet()) {
if(entry.getValue().equals(likeList)){
index = entry.getkey();
}
}
你有什么主意吗?
尝试这个。这只是流原始列表的entrySet和
版画
注意,列表的顺序很重要。