I have done the code but when I submit it it's coming wrong logic is correct

Scanner sc = new Scanner(System.in);
			int N=sc.nextInt();
			Stack<Integer> stack = new Stack<>();
			for(int i = 0; i< N; i++){
				stack.push(sc.nextInt());
			}
			Stack<Integer> helper = new Stack<>();
			System.out.print("Original Stack=");
			
			// System.out.print(;
			System.out.print(stack);
			System.out.print("<-TOP");
			
			System.out.println();
			
			
			System.out.print("Reverse Stack=");
			revstac(stack,helper, 0);
			System.out.print(stack);
			System.out.print("<-TOP");

		
		}
		public static void revstac(Stack<Integer> stack, Stack<Integer> helper, int index){
			if(stack.isEmpty()){
				return;
			}
			int item = (int)stack.pop();
			revstac(stack, helper, index+1);
			helper.push(item);
			if(index == 0){
				while(!helper.isEmpty()){
					stack.push(helper.pop());

				}
			}
				
			}
		}

Output the values of the reversed stack with each value in one line each.
what you’re printing is the explanation for the output