Search Java Code Snippets

  Help us in improving the repository. Add new snippets through 'Submit Code Snippet ' link.

#Java - Code Snippets for '#Stack' - 4 code snippet(s) found

 Sample 1. Write a Program to implement stack using an array

public class Stack{
   static int top = 0;
   static Element[] stack = new Element[10];
   static class Element {
      int body;
      Element(int value){
         body = value;
   public static void main(String[] args){
   private static void push(int value){
      Element newElement = new Element(value);
   private static Element poll(){
      Element topElement = stack[top];
      return topElement;

   Like      Feedback     stack

 Sample 2. Usage of Java Collections Stack

Stack<INodeDirectory> directories = new Stack<INodeDirectory>();
for(directories.push((INodeDirectory)inode); !directories.isEmpty(); ) {
   INodeDirectory d = directories.pop();

   Like      Feedback     stack  collections  java.util

 Sample 3. Printing Stack trace using Apache Commons ExceptionUtils

try {

} catch (Exception ex){

   Like      Feedback     Apache Commons ExceptionUtils  Apache commons

 Sample 4. Code Sample / Example / Snippet of org.apache.bcel.classfile.StackMap

    public Attribute copy( final ConstantPool _constant_pool ) {

final StackMap c = (StackMap) clone(); = new StackMapEntry[map.length];

for (int i = 0; i < map.length; i++) {[i] = map[i].copy();



return c;


   Like      Feedback      org.apache.bcel.classfile.StackMap

Subscribe to Java News and Posts. Get latest updates and posts on Java from
Enter your email address:
Delivered by FeedBurner

comments powered by Disqus