View RSS Feed

Recent Blogs Posts

  1. Implementing a Stack in Java

    by , 02-19-2012 at 08: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
  2. Java stack and heap memory

    by , 01-08-2012 at 12:43 PM
    Heap is used to store new objects created by Java. Stack is used to store primitive data types like int and double when they are declared locally. These primitive data types are stored on heap when they are declared globally. Whenever a Java method is called, all the local variables are pushed to stack and its pointer is decremented after completion of that method call. In a multithreaded application only one heap is used and each thread contains its own stack. So do not declare your data globally ...