View RSS Feed

Stack

Stack 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
  2. Implementing a Stack in Java

    by , 02-19-2012 at 07:13 AM
    This post will be explaining the Java’s Stack implementation. Last in first order policy is used in Stack in which one by one elements get inserted in a sequence which could be retrieved later on in reverse order. Use these 2 methods to insert or read the elements to/from the Stack.

    • Pop()
    • Push()

    Code is given below to show the implementation of LIFP stack. Total elements that are needed to be inserted to Stack will be taken and after which it will be asked ...
    Tags: java stack Add / Edit Tags
    Categories
    Stack
  3. Java Stack Introduction

    by , 02-19-2012 at 07:11 AM
    A stack is basically a data structure which uses the following:

    • Methods for inserting the data by the help of push operation
    • Methods for removal of data by the help of pop operation.


    Peak method is supported by Stack implementations. It will make the head to be read without removal from Stack. Last in First out policy is used in Stack. This means that data which has been inserted in data structure at last will be made to get removed first.

    Data ...
    Tags: stack Add / Edit Tags
    Categories
    Queue , Stack