Here you can find the source of lastIndexOf(List super T> list, T element)
Parameter | Description |
---|---|
list | the list |
element | the element |
public static <T> int lastIndexOf(List<? super T> list, T element)
//package com.java2s; //License from project: Open Source License import java.util.List; import java.util.ListIterator; public class Main { /** Returns the last index of a specific elemen in a list. * @param list the list//from w w w.jav a2s .c o m * @param element the element * @return the last index of {@code element} in {@code list}*/ public static <T> int lastIndexOf(List<? super T> list, T element) { ListIterator<? super T> iter = list.listIterator(); int index = -1; while (iter.hasNext()) { Object t = iter.next(); if (element.equals(t)) { index = iter.previousIndex(); } } return index; } }