Sunday 11 May 2014

public LinkedList()

public LinkedList()
Constructs an empty list.

import java.util.*;

class LinkedListEx{
 public static void main(String args[]){
  LinkedList<Integer> myList;
  myList = new LinkedList<> ();
  
  /* Add Elements to myList */
  myList.add(10);
  myList.add(20);
  
  System.out.println("Elements in myList are");
  System.out.println(myList);
 }
}

Output
Elements in myList are
[10, 20]


Prevoius                                                 Next                                                 Home

No comments:

Post a Comment