当包含 返回 true 时,如何在列表中查找元素的索引位置
2022-08-31 12:10:59
我有一个,所以我正在使用来找出列表是否包含指定的.如果是这样,我想从列表中获取该元素,那么我如何找出该元素所在位置的索引位置?List
HashMap
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?