It is very interesting and is probably not because of the brackets.
You can execute the following procedure:
1. Copy the following code:
in the text area of the following site:
https://www.jdoodle.com/online-java-compiler/
2. There is a dropdown under: "Execute Mode, Version, Inputs & Arguments" in this dropdown select: "JDK 11.0.4"
3. Click the "Execute" button.
It is displayed:
/Q14.java:7: error: ')' expected
} catch (Exception e || RuntimeException e) {
^
/Q14.java:7: error: illegal start of expression
} catch (Exception e || RuntimeException e) {
^
/Q14.java:7: error: ';' expected
} catch (Exception e || RuntimeException e) {
^
/Q14.java:7: error: not a statement
} catch (Exception e || RuntimeException e) {
^
/Q14.java:7: error: ';' expected
} catch (Exception e || RuntimeException e) {
^
/Q14.java:10: error: 'finally' without 'try'
} finally {
^
/Q14.java:12: error: reached end of file while parsing
} }}
^
7 errors
When I repeated
the same procedure by only changing the
(the code in the test from the book)
to
(the fixed version)
The result is:
/Q14.java:4: error: incompatible types: try-with-resources not applicable to variable type
try (StringBuilder reader = new StringBuilder()) {
^
(StringBuilder cannot be converted to AutoCloseable)
/Q14.java:7: error: Alternatives in a multi-catch statement cannot be related by subclassing
} catch (Exception | RuntimeException e) {
^
Alternative RuntimeException is a subclass of alternative Exception
/Q14.java:9: error: cannot find symbol
throw new FileNotFoundException();
^
symbol: class FileNotFoundException
location: class Q14
3 errors
As you can see
the message:
/Q14.java:12: error:
reached end of file while parsing
} }}
is not here by only removing the text "e |" from the source code (nothing else is changed).
It makes me to think there is not an issue with the brackets.
The only issue is with an incorrect text in the book:
It should be changed to: