Java examples for Collection Framework:LinkedList
Get first and last elements from LinkedList
import java.util.LinkedList; public class Main { public static void main(String[] args) { LinkedList lList = new LinkedList(); //from ww w . ja va2 s. c o m lList.add("1"); lList.add("2"); lList.add("3"); lList.add("4"); lList.add("5"); System.out.println("First element of LinkedList is : " + lList.getFirst()); System.out.println("Last element of LinkedList is : " + lList.getLast()); } }