如果我在堆栈中存储数字,并且想要在队列中打印它,我是否应该再次在队列中存储相同的数字以打印它,或者有另一种方法可以执行它呢?在堆栈中存储一个数字并将其打印在队列中
import java.util.Stack;
import java.util.PriorityQueue;
import java.util.Scanner ;
public class Qa {
public static void main(String[] args) {
Scanner input = new Scanner (System.in);
Stack<Integer> A =new Stack<Integer>();
System.out.println(" the numbers should be less than 99 ");
int x = input.nextInt() ;
while(x> 0 && x < 99){
A.push(x);
}
PriorityQueue<String> B =new PriorityQueue<String>();
}
非常感谢:) – alex213