Online Java Compiler By
JavaTpoint.com
import java.util.*; public class CollectionsIndexOfSubListExample2 { public static void main(String[] args) { //Create lists for source and destination List
source = Arrays.asList(3,4,5); List
target = Arrays.asList(1,2,3,4,5,6,7,8); //Check target list in source list int index = Collections.indexOfSubList(target, source); System.out.println("Target list starts at index: "+index); } }
Output