<java>Table for Multi Arrays
domxaline
Messages postés
188
Date d'inscription
Statut
Membre
Dernière intervention
-
domxaline -
domxaline -
Bonjour,
Bonjour,
en compilant ce prg j'ai le message suivant
This is the firsts array
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2
8 9
at javaapplication1.Arrays.display(Arrays.java:17)
at javaapplication1.Arrays.main(Arrays.java:11)
12 13
veuillez m'aidez s'il vous plaît
Bonjour,
package javaapplication1; //import java.util.*; public class Arrays { public static void main(String []args) { int firstarray[][]={{8,9,10,11},{12,13,14,15}}; int secondarray[][]={{30,31,32,33},{43},{4,5,6}}; System.out.println("This is the firsts array"); display(firstarray); System.out.println("This is the second array"); display(secondarray); } public static void display(int x[][]) { for(int row=0;row<x[row].length;row++) { for(int column=0;column<x.length;column++) { System.out.print(x[row][column]+"\t"); } System.out.println(); } } }
en compilant ce prg j'ai le message suivant
This is the firsts array
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2
8 9
at javaapplication1.Arrays.display(Arrays.java:17)
at javaapplication1.Arrays.main(Arrays.java:11)
12 13
veuillez m'aidez s'il vous plaît
A voir également:
- <java>Table for Multi Arrays
- Waptrick java football - Télécharger - Jeux vidéo
- Jeux java itel - Télécharger - Jeux vidéo
- Table ascii - Guide
- Downloader for pc - Télécharger - Téléchargement & Transfert
- Table des matières word - Guide
1 réponse
ça y est ,j'ai corrigé mon erreur
volia la corrrection:
volia la corrrection:
package javaapplication1; //import java.util.*; public class Arrays { public static void main(String []args) { int firstarray[][]={{8,9,10,11},{12,13,14,15}}; int secondarray[][]={{30,31,32,33},{43},{4,5,6}}; System.out.println("This is the firsts array"); display(firstarray); System.out.println("This is the second array"); display(secondarray); } public static void display(int x[][]) { for (int column = 0 ; column < x.length ; column++) { for (int row = 0 ; row < x[column].length ; row++) { System.out.print(x[column][row]+"\t"); } System.out.println(); } } }