View RSS Feed

Algorithm and Data Structure

Algorithm and data structure examples in Java.

  1. Java's Stack Class

    by , 02-19-2012 at 07:16 AM
    Stack is considered to be a data structure which used last in first out policy. New elements could be added or removed to/from the top of Stack. Queue uses First in First out mechanism as compared to Stack.

    Java Code: Stack usage is explained by this code
    Stack myStack = new Stack();
    myStack.push("1");
    myStack.push("2");
    myStack.push("3");
    //look at top object ("3"), without taking it off the stack.    
    Object topObj = stack.peek();
    Object
    ...
    Tags: stack class Add / Edit Tags
    Categories
    Stack