Code:
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
ArrayList<Integer> array = new ArrayList<>();
while(scanner.hasNextInt()){
array.add(scanner.nextInt());
}
System.out.println(array);
}
}
Input: enter image description here
Why while doesnt brake the loop when i enter empty line?