Reading int

Report a typo

Take a look at the following code. It reads the first mention of int in the file.

String pathToFile = "file.txt";
try (Scanner scanner = new Scanner(new File(pathToFile))) {
    System.out.println(scanner.nextInt());
}

If file.txt consists of these lines:

start line
line two
end line

What will be printed out in the console?

Hint: to find the right answer you may run this piece of code on your computer and check the result.

Select one option from the list
___

Create a free account to access the full topic