By candid | Posted :
Jun 24, 2015
| Updated :
Jun 24, 2015
Appends the specified element to the end of this list.
Program
package com.candidjava;
import java.util.LinkedList;
/**
*
* @author : mohan
* @description :The java.util.LinkedList.addLast(E e) method inserts the
* specified element at the end of this list.
*/
public class LinkedListAddLast {
public static void main(String[] args) {
LinkedList list = new LinkedList();
list.add("anandh");
list.add("hari");
list.add("vinoth");
list.add("kamal");
System.out.println("LinkedList:" + list);
list.addLast("I am Last:-( ");
System.out.println("LinkedList:" + list);
}
}
Output
LinkedList:[anandh, hari, vinoth, kamal]
LinkedList:[anandh, hari, vinoth, kamal, I am Last:-( ]
Explanation
public void addLast(E e)
Appends the specified element to the end of this list.