Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 17th, 2012  |  syntax: None  |  size: 0.35 KB  |  hits: 20  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. public class ArrayStack<E> {
  2.        
  3.         private E arrayOfStack[];
  4.         private int top = -1;
  5.         private int capacity = 10;
  6.        
  7.         public ArrayStack() {
  8.                 arrayOfStack = (E[]) new Object[capacity];
  9.         }
  10.  
  11.         public int size()
  12.         {
  13.                 return top +1;
  14.         }
  15.        
  16.                 public boolean isEmpty()
  17.         {
  18.                 if(top==-1)
  19.                 {
  20.                         return true;
  21.                 }
  22.                 else
  23.                 {
  24.                         return false;
  25.                 }
  26.                
  27.         }
  28. }