The program does not compile. What mistake

I am trying to run the simple code below on the command line in the last few hours. Still unable to fix the error.

What is the problem. I can not find.

Here is the code:

public static void main(String[] args) {
        int i;
        try {
            DataInputStream din = new DataInputStream(System.in);
            i = Integer.parseInt(din.readLine());
        }
        catch(NumberFormatException || IOException exception) {
            System.out.println(exception.getMessage());
        }
}
+4
source share
1 answer

You must use a single operator |. Do not ||.

catch(NumberFormatException | IOException exception)
+10
source

Source: https://habr.com/ru/post/1535070/


All Articles