Probleme de compilation
sandy
-
Sandy -
Sandy -
Bonjour,
voici mon programme je suis novice en java et je ne comprends pas pk ça ne marche pas on me dit:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2
at essai2.main(essai2.java:14)
import java.util.Scanner;
public class essai2 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in) ;
int contenance = sc.nextInt();
int pvd = 0;
int premiersNombres[][] = { {30,50,100},{43,64,79} };
if (contenance == 30) {
pvd = premiersNombres[2][1];
}
if (contenance == 50) {
pvd = premiersNombres[2][2];
}
if (contenance == 30) {
pvd = premiersNombres[2][3];
}
System.out.println ("le prix de vente est " + pvd);
}}
voici mon programme je suis novice en java et je ne comprends pas pk ça ne marche pas on me dit:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2
at essai2.main(essai2.java:14)
import java.util.Scanner;
public class essai2 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in) ;
int contenance = sc.nextInt();
int pvd = 0;
int premiersNombres[][] = { {30,50,100},{43,64,79} };
if (contenance == 30) {
pvd = premiersNombres[2][1];
}
if (contenance == 50) {
pvd = premiersNombres[2][2];
}
if (contenance == 30) {
pvd = premiersNombres[2][3];
}
System.out.println ("le prix de vente est " + pvd);
}}
A voir également:
- Probleme de compilation
- Breach compilation c'est quoi - Guide
- Compilation html ✓ - <a href="https://forums.commentcamarche.net/forum/html-273">Forum HTML</a>
- Compilation fichier pdf - Guide
- Erreur de compilation ✓ - <a href="https://forums.commentcamarche.net/forum/excel-145">Forum Excel</a>
- Erreur de compilation ✓ - <a href="https://forums.commentcamarche.net/forum/bureautique-25">Forum Bureautique</a>
Je sais que le tableau fonctionne mais juste l affichage ne marche pas