如何让它运行?我有一个堆栈,我将String推入堆栈,我打印堆栈,我是否还要弹出堆栈以使其运行?
import java.util.*;
public class Stacks {
public static void main(String args) {
Scanner input = new Scanner(System.in);
String words;
String DONE = null;
Stack<String> series = new Stack<String>();
System.out.println("Enter a series of words or 'DONE' to quit");
words = input.nextLine();
series.push(words);
while (!words.equals("DONE")) {
System.out.println(series);
System.out.println("Enter a series of words or 'DONE' to quit");
words = input.nextLine();
if (words.equals("DONE")) {
break;
}
}
}
}