Sunday 17 May 2015

How to create LinkedList in Java



import java.util.LinkedList;

public class CreateLinkList {
   
public static void main(String[] args) {
   
    LinkedList<String> linkedList = new LinkedList<String>();

    linkedList.add("Mumbai");
    linkedList.add("Delhi");
    linkedList.add("Noida");
    linkedList.add("Gao");
    linkedList.add("Patna");

    System.out.println("Linklist is"+linkedList);

}

}

Output:

Linklist is = [Mumbai, Delhi, Noida, Gao, Patna]
 

No comments:

Post a Comment