Demande explication ArrayIndexOutOfBoundException
bonjour
le program suivant s'affiche un output
"ArrayIndexOutOfBoundsException block2"
quelqu'un peut m'aider pourquoi il affiche "OutOfBoundsException"
merci d'avance
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
public class Excep1
{
public static void main(String[]args)
{
try
{
int n=Integer.parseInt(args[0]);
int n1=Integer.parseInt(args[1]);
int n2;
n2=n+n1;
}
catch(ArithmeticException ex)
{
System.out.println("Arithmetic Exception block1");
}
catch(ArrayIndexOutOfBoundsException ex)
{
System.out.println("ArrayIndexOutOfBoundsException block2");
}
}
} |