Related Examples
 

Java LinkedList class addLast method example code

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


LinkedList class addLast method example.public void addLast(LinkedList e) Appends the specified element to the end of this list.

Here is the code

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

public class AddFirst {

    public static void main(String args[]) {
        LinkedList list = new LinkedList();

        String str = "Rose";

        //Add the specified element to the end of this list.

        list.add(str);
        list.add("India");
        System.out.println("list " + list);

        //Add the specified element to the First of this list.
        list.addFirst("356");
        System.out.println("list = " + list);
    }
}

Output
list [Rose, India]
list = [Rose, India, 356]

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

HOME | COPYRIGHT | CONTACT US