Online Java Compiler By
JavaTpoint.com
import java.util.LinkedList; import java.util.List; public class JavaListSubListExample_3 { public static void main(String[] args) { List
list= new LinkedList<>(); for (char ch='a';ch<='z';ch++){ list.add(ch); } System.out.println("Total alphabets : "+list.size()); //if fromIndex<-1 || toIndex< -1 it will throw an exception System.out.println("List : "+list.subList(-1,-1)); } }
Output