[Solved] The opposite of .get() (ArrayList) [duplicate]


You can use the .indexOf(Object o) method which returns, as the java 8 documentation specifies:

the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element

You can also use .lastIndexOf(Object o) which, as you would guess, will return the last occurrence of the specified element.

Please consult the documentation for more details.

Cheers.

solved The opposite of .get() (ArrayList) [duplicate]