How to get index no of two same item in a list

An amazing workaround:
List< Integer > inlist = new ArrayList<>();
while(list.contains(xyz)){
int i = list.indexof(xyz);
inlist.add(i);
list.remove(i);
}

2 Likes