Skip to content

Instantly share code, notes, and snippets.

@uncoded-ro
Created January 12, 2020 07:15
Show Gist options
  • Save uncoded-ro/f8697122934fccf4a36dd61e11c3bc76 to your computer and use it in GitHub Desktop.
Save uncoded-ro/f8697122934fccf4a36dd61e11c3bc76 to your computer and use it in GitHub Desktop.
package ro.virtualcampus.exceptii;
public class TratareExceptii {
public static void main(String[] args) {
int nr = 0;
try {
nr = Integer.parseInt(args[0]);
} catch (NumberFormatException e) {
System.out.println("NumberFormatException");
nr = 1;
} catch (ArrayIndexOutOfBoundsException e) {
System.out.println("ArrayIndexOutOfBoundsException");
nr = 2;
} finally {
nr++;
}
System.out.println("nr = " + nr);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment