Stack in java.util : Stack « Collections Data Structure « Java






Stack in java.util

Stack in java.util
     

import java.util.Stack;

public class StackExample {
  public static void main(String args[]) {
    Stack s = new Stack();
    s.push("Java");
    s.push("Source");
    s.push("and");

    System.out.println("Next: " + s.peek());
    s.push("Support");
    System.out.println(s.pop());
    s.push(".");
    int count = s.search("Java");
    while (count != -1 && count > 1) {
      s.pop();
      count--;
    }
    System.out.println(s.pop());
    System.out.println(s.empty());
  }
}

           
         
    
    
    
    
  








Related examples in the same category

1.Demonstration of Stack ClassDemonstration of Stack Class
2.Stack data structureStack data structure
3.Bracket Checker
4.String Reverser Through Stack String Reverser Through Stack
5.Link stackLink stack
6.Triangular numbersTriangular numbers
7.Triangular numbers with stack replaces recursionTriangular numbers with stack replaces recursion
8.Show String ReversalsShow String Reversals
9.Generic stack demo with annotation
10.Character Stack
11.A faster, smaller stack implementation.
12.Growable Object stack with type specific access methods
13.Growable int stack with type specific access methods
14.Stack for boolean values
15.extends ArrayList to create Stack
16.Growable String stack with type specific access methods.
17.A simple integer based stack.
18.A very simple unsynchronized stack. This one is faster than the java.util-Version.
19.Pop an empty stack ntry times and catch the resulting exceptionPop an empty stack ntry times and catch the resulting exception
20.Object Stack
21.Fast stack