Online Java Compiler By
JavaTpoint.com
import java.util.*; public class CollectionsLastIndexOfSubListExample1 { public static void main(String[] args) { //Create Source array list objects List
srclist = new ArrayList<>(); //Add elements in the list srclist.add("A"); srclist.add("B"); srclist.add("C"); srclist.add("D"); srclist.add("E"); //Create Target array list objects List
targetlist = new ArrayList<>(); //Add elements in the list targetlist.add("C"); targetlist.add("D"); targetlist.add("E"); //Check target list in source list int index = Collections.lastIndexOfSubList(srclist, targetlist); System.out.println("Target Output: "+index); } }
Output