Related Examples
 

Java LinkedList pollLast Example

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


LinkedList class pollLast method example.public LinkedList pollLast() Retrieves and removes the last element of this list, or returns null if this list is empty

Here is the code

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

public class PollLast {

    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);

        //Remove and display last element
        System.out.println("Remove last element = " + list.pollLast());
        System.out.println("list = " + list);
    }
}

Output
Remove last element = Rose
list = [11]

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

HOME | COPYRIGHT | CONTACT US