Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Main {
    public static void main(String args[]) {
        // create two array list objects       
        List<String> arrlistsrc = new ArrayList<String>();
        List<String> arrlisttarget = new ArrayList<String>();

        // populate two lists
        arrlistsrc.add("A");
        arrlistsrc.add("from java2s.com");
        arrlistsrc.add("C");
        arrlistsrc.add("D");
        arrlistsrc.add("E");

        arrlisttarget.add("C");
        arrlisttarget.add("D");
        arrlisttarget.add("E");

        // check target list in source list
        int index = Collections.indexOfSubList(arrlistsrc, arrlisttarget);

        System.out.println("Target list starts at index: " + index);
    }
}