-
-
Save uncoded-ro/f8697122934fccf4a36dd61e11c3bc76 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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