我得到了 HashMap的 List,所以我使用 List.contains来查看列表是否包含指定的 HashMap。如果需要,我想从列表中提取元素,那么如何找到元素所在位置的索引位置呢?
List benefit = new ArrayList();
HashMap map = new HashMap();
map.put("one", "1");
benefit.add(map);
HashMap map4 = new HashMap();
map4.put("one", "1");
System.out.println("size: " + benefit.size());
System.out.println("does it contain orig: " + benefit.contains(map));
System.out.println("does it contain new: " + benefit.contains(map4));
if (benefit.contains(map4))
//how to get index position where map4 was found in benefit list?