3:06 pm - Saturday September 26, 3091

LinkedList Example Program for poll()

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044

/*Remove and retrieve the head of the list using poll() and class Poll*/
/**
*@Author: candidjava.com
*@Description: Remove and retrieve the head of the list using poll() and class Poll
*/
import java.util.*;

public class LinkedListPoll {
   public static void main(String args[])
   {
     LinkedList<String> ls=new LinkedList<String> ();//create ls object for LinkedList
      ls.add("welcome");//add content to the ls
      ls.add("to");//add content to the ls
      ls.add("chennai");//add content to the ls
      System.out.println("linkedlist:"+ls);
      System.out.println("remove head ele of the list:"+ls.poll());/*removeĀ  and retrives the head of the list*/
      System.out.println("linkedlist:"+ls);
   }
}

Output:

linkedlist:[welcome,to,chennai]
remove head ele of the list:welcome
linkedlist:[to,chennai]

BACK

Filed in: Z-A All Java Codes

Comments are closed.