3:31 pm - Sunday June 25, 2017

Collections Example program for indexOfSubList(List source, List target)

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044
/**

@description:Collections Example program for indexOfSubList(List Source, List target)
@author:candidjava.com
 */

import java.util.List;
import java.util.Collections;
import java.util.Arrays;

public class CollectionsIndexOfSubList {
	public static void main(String[] args) {

		List l1 = Arrays.asList("king mani santhos karthi santhanam sathish"
				.split(" ")); // creating array list with values

		System.out.println("List :" + l1); // printing array list

		List sublist = Arrays.asList("karthi santhanam".split(" ")); // Sublist
																		// which
																		// we
																		// need
																		// indexof

		Integer ciosl = Collections.indexOfSubList(l1, sublist); // Index of
																	// sublist
																	// in ciosl
																	// integer

		System.out.println("indexOfSubList: " + ciosl); // printing
														// indexofsublist
	}
}

Output:

List :[king, mani, santhos, karthi, santhanam, sathish]
indexOfSubList: 3

BACK

Filed in: Z-A All Java Codes

Comments are closed.