Java LinkedList push Example
LinkedList class push method example. This example shows you how to use push method.
LinkedList class push method example.public void push(LinkedList e) Pushes an element onto the stack represented by this list. In other words, inserts the element at the front of this list.
Here is the code
/**
* @ # Push.java
* A class repersenting use to push method of LinkedList class in java.util package
* version 15 May 2008
* author Rose India
*/
import java.util.*;
public class Push {
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);
//inserts the element at the front of this list.
list.push("India");
System.out.println("list = " + list);
}
} |
|