package com.codegym.task.task07.task0722;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
/*
The end
*/
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
ArrayList<String>list=new ArrayList<>();
//write your code here
while (true)
{
String s= reader.readLine();
if (s.equals("end"))
break;
list.add(s);
}
for (String S:list
) {
System.out.println(S);
}
}
}
break statement confusion. why the line after that is being read. can some one explain?
Under discussion
Comments (1)
- Popular
- New
- Old
You must be signed in to leave a comment
Roman
4 October 2019, 13:47
What are you talking about?
For the input:
"test4" (after break) will not be read and the output will be:
0