How to find index position of an element in a list when contains returns true
Solution 1:
benefit.indexOf(map4)
It either returns an index or -1 if the items is not found.
I strongly recommend wrapping the map in some object and use generics if possible.
Solution 2:
Here is an example:
List<String> names;
names.add("toto");
names.add("Lala");
names.add("papa");
int index = names.indexOf("papa"); // index = 2
Solution 3:
indexOf(object)
get(index)
Solution 4:
Use List.indexOf()
. This will give you the first match when there are multiple duplicates.
Solution 5:
List#indexOf