Bonjour à tous,
Il y a une erreur que j'arrive pas à corriger dans le code suivant:

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
 
public static void compareMatrices(char[][] mat1, char[][] mat2 ,String ch,int n) {
		ArrayList<Point> list = new ArrayList<Point>();	
		 n=ch.length()+1;
		for (int i = 0;i<n;i++) {
			for (int j = 0;j<mat1[0].length;j++) {
				if (mat1[i][j] != mat2[i][j]) {
					list.add(new Point(i+1,j+1));
					mat2[i][j] = mat1[i][j];
				}
			}
		}
		for (Point p : list) {
			System.out.println("nouvelle valeur Matrice2("+((int)p.getX()+","+ (int)p.getY()+") = " + mat2[(int)p.getX()][(int)p.getY()]));
			System.out.println();
		}
Voici l'erreur
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
 
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 8
	at M.compareMatrices(M.java:14)
Autre chose je ne comprend pas non plus pourquoi le code considère les lignes de 2 jusque à n toutes erronées pourtant ce n' est pas le cas.

Merci à vous.