Reverse a stack

My program for reversing a stack is not working pls look into the matter

public class Reversestack {

public static void main(String[] args) throws Exception  {
	stackoperations stack=new stackoperations(5);
	for(int i=1;i<=5;i++) {
		stack.push(i*10);}
		stack.display();
		stackoperations helper=new stackoperations(5);
		reverseStack(stack,helper,0);
		stack.display();
	}
public static void  reverseStack(stackoperations stack,stackoperations helper,int index) throws Exception {
if(stack.isEmpty()) {
	return;
}
	int item=stack.pop();
  reverseStack(stack,helper,index+1);
  helper.push(item);
  if(index==0) {
	  while(!helper.isEmpty()) {
		  stack.push(helper.pop());
	  }
  
}
}

}

please also send the code of stackoperations as it is a user defined structure. also what error is it throwing?

try moving the
while(!helper.isEmpty()) {
stack.push(helper.pop());
}
block into the main function. Also please reply here only as notifications are enabled for discuss and not chat.

I have used the same line of code pls check it and run or send the possible solution

use an array instead of the second stack