Related Examples
 

Java LinkedList removeFirst Example

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


LinkedList class removeFirst method example.public LinkedList removeFirst() Removes and returns the first element from this list.

Here is the code

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

public class RemoveFirst {

    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);
        list.add("India");

        //Remove first element
        System.out.println(list.removeFirst());
        System.out.println("list = " + list);
    }
}

Output
11
list = [Rose, India]

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

HOME | COPYRIGHT | CONTACT US