I have problems when testing my code. I think that the problem has to do with using a BufferedReader reading from an InputStreamReader. I used IntelliJ and give the following input:
Hello
World!
Why is my program not printing anything? Here is my code:
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
Deque<String> lines = new ArrayDeque<>();
String line = br.readLine();
while (line != null) {
lines.push(line);
line = br.readLine();
}
while (!lines.isEmpty()) {
System.out.println(lines.pop());
}
}