Code issue , , , , , , ,, , , , , ,, , , , ,, ,, , , , ,

import java.util.*;
class Main
{
public static void main(String[] args)
{
Stack s=new Stack();
s.push(50);
s.push(40);
s.push(30);
s.push(20);
s.push(10);
Stack h=new Stack();
check(s,h,0);

}
public static void check(Stack<Integer> s,Stack<Integer> h,int index)
{
    if(s.isEmpty())
    {
        return;
    }
    int n=s.pop();
    check(s,h,index+1);
    h.push(n);
    if(index==0)
    {
        while(!h.isEmpty())
        {
            s.push(h.pop());
        }
    }
}
}

sir output same hi aari h mtlb reverse order m nhi aari .

Hey @Nitin-Mishra-2380486738834604
reverse aa raha h
code is fine
[50, 40, 30, 20, 10]
[10, 20, 30, 40, 50]