/**
* put item on top of stack
* @param j
*/
public void push(long j){
//stack array is not full
if(!this.isFull()){
//increment top,insert item
stackArray[++top]=j;
}else{
System.out.println("stack array is full!");
}
}
/**
* take item from top of stack
* @return
*/
public long pop(){
//stack array is not empty
if(!this.isEmpty()){
//access item,decrement top
return stackArray[top--];
}else{
return -1;
}
}
/**
* peek at top of stack
* @return at top item of stack array
*/
public long peek(){
return stackArray[top];
}
/**
* true if stack is empty
* @return
*/
public boolean isEmpty(){
return (top==-1);
}
/**
* true if stack is full
* @return
*/
public boolean isFull(){
return (top==maxSize-1);
}
while(!ss.isEmpty()){
//take item pop from stack array
long tempValue=ss.pop();
//peek pop item from stack array
System.out.println("pop="+tempValue);
}