I wrote a method that receives a queue as a parameter and then convert this queue into a stack. Now I want to try to print this method in the main to see if it works, but there isn't any toString method for stacks.
I already did some research and tried to convert stacks into arrays, but I can't get it to work. Printing the stack values in Java
How can I do this?
public static void QueueStack(Queue<Integer> q){
Stack<Integer> stack1 = new Stack<Integer>();
while(!q.isEmpty()){
int temp = q.dequeue();
stack1.push(temp);
}
Arrays.toString(stack1.toArray());
}