Online Java Compiler By
JavaTpoint.com
import java.util.*; public class VectorSubListExample2 { public static void main(String arg[]) { //Create an empty vector Vector < String > vec = new Vector < String > (); //Add elements in the vector vec.add("White"); vec.add("Green"); vec.add("Black"); vec.add("Orange"); vec.add("Yellow"); vec.add("Pink"); //Display the vector elements System.out.println("The vector elements are: "+vec); //Use subList() method to get subList of the vector List
subList = vec.subList(1,5); //Display sublist vector list System.out.println("Sublist elements :"+subList); } }
Output