Operation on LinkedList // Linked List of collection framework

 The following code is on the LinkedList of collection framework

package com.linklist;


import java.util.LinkedList;


public class LinkedList2 {

public static void main(String[] args) {

//creating

LinkedList<String> lk = new LinkedList<String>();

//Adding element

lk.add("E");

lk.add("D");

lk.add("M");

lk.add("N");

lk.add(2,"P");

System.out.println(lk);

lk.remove("D");

System.out.println(lk);

lk.remove(2);

System.out.println(lk);

lk.removeFirst();

System.out.println(lk);

lk.removeLast();

System.out.println(lk);



}

}

//output

[E, D, P, M, N]

[E, P, M, N]

[E, P, N]

[P, N]

[P]

Comments

Popular posts from this blog

Operation on ArrayList in java

ArrayList program // collection framework in java

Vector in java collection, Vector object default creating and generic creation in class