This compiles correctly, but it shows wrong answer

for(int i=0;i<q;i++){
if(s.nextInt()==2){
stack.push(s.nextInt());
}else{
System.out.println( stack.pop());
}
}

Hi @Hardik-Bhardwaj-392610454600906
Please share your code so that i can debug and find the error and help you better