Bonjour à tous,
J'ai besoin d'un ISBN pour un exo sur une bibliothèque et j'ai trouvé sur le net cette classe :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 
public class ISBN {
 
    public static void main(String[] args)  { 
 
        // read in one command-line argument
        int n = Integer.parseInt(args[0]);
 
        // compute the weighted sum of the digits, from right to left
        int sum = 0;
        for (int i = 2; i <= 10; i++) {
            int digit = n % 10;                // rightmost digit
            sum = sum + i * digit;
            n = n / 10;
        }
 
        // print out check digit, use X for 10
        System.out.print("The full ISBN number is " + args[0]);
        if      (sum % 11 == 1) System.out.println("X");
        else if (sum % 11 == 0) System.out.println("0");
        else                    System.out.println(11 - (sum % 11));
    }
}
J'ai sur l a ligne
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
 
 int n = Integer.parseInt(args[0]);
l'erreur "Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0" qui je pense à cause de la dimension de mon tableau, mais je n'arrive pas à trouver comment y remédier et je ne sais pas comment lancer cette classe avec un argument (args).
Si quelqu'un peut m'aider MERCI