/* Tests d'egalite entre 2 tableaux */ public class TestEgaliteTableaux { /* Fonction de test de l'egalite de 2 tableaux */ /* d'entiers */ static boolean testEgalite(int [] ta,int [] tb) { boolean res; int i; res = true; if ( ta.length != tb.length ) { res = false; } else { i = 0; while ( ( res == true ) && ( i < ta.length ) ) { if ( ta[i] != tb[i] ) { res = false; } i = i+1; } } return res; } /* Programme principal */ public static void main(String [] args) { int [] t1 = { 0,1,2,3 }; int [] t2 = { 0,0,0,0 }; int [] t3 = { 0,1,2,3 }; boolean egal; egal = (t1 == t2); Ecran.afficherln(egal); egal = (t1 == t3); Ecran.afficherln(egal); egal = testEgalite(t1,t2); Ecran.afficherln(egal); egal = testEgalite(t1,t3); Ecran.afficherln(egal); } }