سؤال

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());
        }
}
هل كانت مفيدة؟

المحلول

Need to use single | operator. Not ||.

catch(NumberFormatException | IOException exception)
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top