Example usage for java.util Stack push

List of usage examples for java.util Stack push

Introduction

In this page you can find the example usage for java.util Stack push.

Prototype

public E push(E item) 

Source Link

Document

Pushes an item onto the top of this stack.

Usage

From source file:MainClass.java

public static void main(String args[]) {
    Stack s = new Stack();
    s.push("A");
    s.push("B");//from  w w  w  .j  av a 2 s . c o m
    s.push("C");

    System.out.println("Next: " + s.peek());
}

From source file:MainClass.java

public static void main(String args[]) {
    Stack s = new Stack();
    s.push("A");
    s.push("B");/*  w ww .  j a va 2s .  com*/
    s.push("C");

    System.out.println(s);
}

From source file:MainClass.java

public static void main(String args[]) {
    Stack s = new Stack();
    s.push("A");
    s.push("B");// w  ww.j a v a  2  s .co  m
    s.push("C");

    System.out.println(s.pop());

}

From source file:MainClass.java

public static void main(String args[]) {
    Stack s = new Stack();
    s.push("A");
    s.push("B");//from  w w w.ja  v  a 2  s. c o  m
    s.push("C");

    System.out.println(s.pop());
    System.out.println(s.empty());
}

From source file:Main.java

public static void main(String args[]) {

    Stack st = new Stack();

    st.push("Java");
    st.push("Source");
    st.push("from java2s.com");

    System.out.println(st.search("Source"));
}

From source file:Main.java

public static void main(String args[]) {

    Stack st = new Stack();

    st.push("Java");
    st.push("Source");
    st.push("from java2s.com");

    // checking the top object
    System.out.println("Top object is: " + st.peek());
}

From source file:Main.java

public static void main(String args[]) {

    Stack st = new Stack();

    st.push("Java");
    st.push("Source");
    st.push("from java2s.com");

    // checking elements
    System.out.println("Elements in the stack: " + st);
}

From source file:Main.java

public static void main(String args[]) {

    Stack st = new Stack();

    st.push("Java");
    st.push("Source");
    st.push("from java2s.com");

    // removing top object
    System.out.println("Removed object is: " + st.pop());

    // elements after remove
    System.out.println("Elements after remove: " + st);
}

From source file:Main.java

public static void main(String args[]) {
    Stack<String> s = new Stack<String>();
    s.push("A");
    s.push("B");//from  ww w  .j  a  va2 s. c o m
    s.push("C");

    System.out.println("Next: " + s.peek());
}

From source file:Main.java

public static void main(String args[]) {
    Stack<String> s = new Stack<String>();
    s.push("A");
    s.push("B");/*  ww w .  j a  v  a2 s .  c om*/
    s.push("C");

    System.out.println(s.pop());
    System.out.println(s.empty());
}