LinkedList In Java

  • LinkedList shape extends AbstractList class.
  • LinkedList shape implements List in addition to Deque interfaces.
  • LinkedList shape is using doubly linked listing to shop elements inwards list.
  • LinkedList tin concur duplicate elements inwards list.
  • LinkedList is non synchronized.
  • Manipulation is faster inwards linkedlist every bit shifting is non required when novel chemical gene is inserted or deleted from list.
  • You tin purpose it every bit list, stack or queue every bit it implements List in addition to Deque interfaces of collection framework.
LinkedList Hierarchy

LinkedList hierarchy inwards java

Bellow given example volition exhibit yous work of dissimilar methods of linkedlist shape inwards java.

LinkedListExample
package JAVAExamples;  import java.util.LinkedList;  world shape LinkedListExample {  world static void main(String args[]) {   // Prepare linkedlist.   LinkedList lst = novel LinkedList();   // Add elements using add together method.   lst.add("one");   lst.add("two");   lst.add("three");   lst.add("four");   lst.add("five");   lst.add("six");   // Add chemical gene at root seat inwards listing using addFirst.   lst.addFirst("FirstNumber");   // Add chemical gene at final seat inwards listing using addLast.   lst.addLast("LastNumber");   // Add elements at index 1 inwards list.   lst.add(1, "1 number");   System.out.println("List items : " + lst);    // Removing root exceptional from listing using removeFirst method.   lst.removeFirst();   System.out.println();   System.out.println("List items later on removing root exceptional from list: "+ lst);    // Removing final exceptional from listing using removeLast method.   lst.removeLast();   System.out.println();   System.out.println("List items later on removing final exceptional from listing : "+ lst);    // Removing exceptional from listing using value.   lst.remove("two");   System.out.println();   System.out.println("List items later on removing exceptional yesteryear value from listing : "+ lst);    // Removing exceptional from listing using index.   lst.remove(3);   System.out.println();   System.out.println("List items later on removing exceptional yesteryear index from listing : "+ lst);    // Get exceptional from listing using index.   System.out.println();   System.out.println("List exceptional at index 2 is : " + lst.get(2));    // Set exceptional at given index inwards list.   lst.set(2, "Newset Value");   System.out.println();   System.out.println("List items later on set(replace) novel value at index 2 inwards listing : "+ lst);  } }

More interesting articles here :Generation Enggelmundus Internet Marketing Tool here :Zeageat IM http://www.software-testing-tutorials-automation.com/
Post a Comment (0)
Previous Post Next Post