Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Program not compiling. What is the error

I am trying to run the below simple code in command prompt for last few hours. Still not able to fix the error.

What is the problem here. I'm not able to 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());
        }
}
like image 426
user3499151 Avatar asked Dec 25 '22 11:12

user3499151


1 Answers

Need to use single | operator. Not ||.

catch(NumberFormatException | IOException exception)
like image 162
Gokul Nath KP Avatar answered Feb 21 '23 05:02

Gokul Nath KP