LinkdedList:
Doubly-linked list implementation of the List and Deque interfaces. Implements all optional list operations, and permits all elements (including null). All of the operations perform as could be expected for a doubly-linked list. Operations that index into the list will traverse the list from the beginning or the end, whichever is closer to the specified index.
Example
package com.candidjava.core; import java.util.LinkedList; public class LinkedListExample { public static void main(String[] args) { LinkedList < String > ll = new LinkedList < String > (); ll.add("hai"); ll.add("123"); ll.add("mathan"); ll.add("lll"); ll.add("mathan"); ll.add("lll"); ll.add("ramya"); ll.add("suji"); ll.add("ravathi"); ll.add("sri"); System.out.println("Linked List .. " + ll); System.out.println("size ... " + ll.size()); System.out.println("peek ... " + ll.peek()); System.out.println("poll ..." + ll.peekLast()); System.out.println("Linked List .. " + ll); System.out.println("size ... " + ll.size()); } }
Output:
Linked List .. [hai, 123, mathan, lll, mathan, lll, ramya, suji, ravathi, sri] size ... 10 peek ... hai poll ...sri Linked List .. [hai, 123, mathan, lll, mathan, lll, ramya, suji, ravathi, sri] size ... 10