LinkedList boolean add(E e) method Example Program
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.add(E e) method appends the specified
* element to the end of this list.
*
*/
public class LinkedListAdd {
public static void main(String[] args) {
LinkedList list = new LinkedList();
list.add("karthi");
list.add("mohan");
list.add("anand");
list.add("hari");
System.out.println("LinkedList:" + list);
list.add("vinoth");
System.out.println("LinkedList:" + list);
}
}
Output
LinkedList:[karthi, mohan, anand, hari]
LinkedList:[karthi, mohan, anand, hari, vinoth]
Explanation
public boolean add(E e)
Appends the specified element to the end of this list.