Related Examples
 

Java LinkedList peekLast Example

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


LinkedList class peekLast method example.public LinkedList peekLast() Retrieves, but does not remove, the last element of this list, or returns null if this list is empty.

Here is the code

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

public class PeekLast {

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

        //peek Last of the list
        System.out.println("Last peek element = " + list.peekLast());
    }
}

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