Related Examples
 

Java LinkedList pop Example

LinkedList class pop method example. This example shows you how to use pop method.


LinkedList class pop method example. public LinkedList pop() Pops an element from the stack represented by this list. In other words, removes and returns the first element of this list.

Here is the code

/**
 * @ # Pop.java
 * A class repersenting use to pop method of LinkedList class in java.util package
 * version 15 May 2008
 * author Rose India 
 */
import java.util.*;

public class Pop {

    public static void main(String args[]) {
        LinkedList list = new LinkedList();
        int i = 11;
        String str = "Rose";

        //Add the specified element to the end of this list.
        list.add(i);
        list.add(str);

        //removes and returns the first element of this list. 
        System.out.println("Removes and returns the " +
                "first element of this list.  = " + list.pop());
        System.out.println("list = " + list);
    }
}

Here is the code
Removes and returns the first element of this list.  = 11
list = [Rose]

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US