What is wrong in code?

import java.util.*;
class dequeueeffqueuechallange {

Stack<Integer> ps= new Stack();
public int dequeue() throws Exception {
	try {
		return ps.pop();
	}
	catch(Exception e) {
		throw new Exception("queue is empty");
	}
}
public void enqueue(int item) throws Exception {
	try {
		Stack<Integer> hs= new Stack();
		
		while (ps.size() !=0) {
			hs.push(ps.pop());
		}
		hs.push(item);
		while(hs.size() !=0) {
			ps.push(hs.pop());
		}
		
		
	}
	catch(Exception e) {
		throw new Exception("queue is full");
	}
}

}

public class Main {

public static void main(String[] args) throws Exception {
	Scanner scn = new Scanner(System.in);
	int n = scn.nextInt();
	int [] arr=new int [n];
	for(int i=0;i<arr.length;i++) {
		arr[i]=i;
		
	}
	dequeueeffqueuechallange queue=new dequeueeffqueuechallange();
	for(int i=0;i<arr.length;i++) {
		queue.enqueue(arr[i]);
	}
	for(int i=0;i<n;i++) {
		System.out.println(queue.dequeue());
	}
	

}

}

your code logic is entirely correct, but your output format is wrong. You need to print all the numbers in the output in the same line while you are printing them on different lines.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.