By candid | Posted :
Jun 30, 2015
| Updated :
Jun 30, 2015
Pushes an element onto the stack represented by this list. In other words, inserts the element at the front of this list.
This method is equivalent to addFirst(E).
Program
package com.candidjava;
import java.util.LinkedList;
/**
*
* @author : mohan
* @description :The java.util.LinkedList.push(E e) method pushes an element
* onto the stack represented by this list. In other words, inserts
* the element at the front of this list.
*/
public class LinkedListPush {
public static void main(String[] args) {
LinkedList list = new LinkedList();
list.add("anandh");
list.add("hari");
list.add("vinoth");
list.add("mohan");
list.add("kamal");
System.out.println("LinkedList:" + list);
list.push("ASWIN");
System.out.println("LinkedList:" + list);
}
}