problème ds main(String [] args)
bonjour tout le monde je suis débutant et je trouve un problème quand j'éxécute mon code car j'ai une exception qui dit
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
at ExTestDrive.main(ExTestDrive.java:25)
en sachant que la compilation n'affiche aucune d'erreur.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| class MyEx extends Exception{ }
public class ExTestDrive{
static void prendreRisque(String t) throws MyEx{
System.out.print("a");
if ("non".equals(t)){
throw new MyEx();
}
System.out.print("n");
}
public static void main(String[] args){
String test = args[0];
try{
System.out.print("l");
prendreRisque(test);
System.out.print("c");
}catch(MyEx e){
System.out.print("v");
}finally{
System.out.print("e");
System.out.print("r");
}
}
} |
en plus le tableau de string qui est dans l'argument du main il sert a quoi.
merci pour votre patience