find Trailing Item in a List - Java java.util

Java examples for java.util:List Search

Description

find Trailing Item in a List

Demo Code


//package com.java2s;
import java.util.List;

public class Main {
    public static <E> E findTrailingItem(final List<E> list, final E item) {
        boolean takeNextItem = false;

        for (E x : list) {
            if (takeNextItem) {
                return x;
            } else if (x == item) {
                takeNextItem = true;/* w w w. j av a  2 s.  co m*/
            }
        }

        return null;
    }
}

Related Tutorials