/* Test de l'utilisation des tableaux */ /* en parametre de methode */ public class PassageTableauEnParametre { /* Passage d'un tableau en parametre */ /* Modification du tableau a l'interieur */ /* de la methode */ /* -> Modification du tableau sur lequel */ /* la methode a ete appelee */ static void testPassage(int [] tab) { int i; for ( i = 0 ; i < tab.length ; i = i+1 ) { Ecran.afficher(tab[i]," "); } Ecran.sautDeLigne(); for ( i = 0 ; i < tab.length ; i = i+1 ) { tab[i] = 9; } for ( i = 0 ; i < tab.length ; i = i+1 ) { Ecran.afficher(tab[i]," "); } Ecran.sautDeLigne(); } /* Retour d'un tableau par une action */ /* apres declaration et initialisation */ static int [] testRetour() { int [] tab = { 0,0,0,0,1,1,1,1 }; return tab; } /* Programme principal */ public static void main(String [] args) { int i; /* Test de la methode testPassage */ int [] t1 = { 0,1,2,3,4,5,6,7 }; testPassage(t1); for ( i = 0 ; i < t1.length ; i = i+1 ) { Ecran.afficher(t1[i]," "); } Ecran.sautDeLigne(); Ecran.sautDeLigne(); /* Test de la methode testRetour */ int [] t2; t2 = testRetour(); for ( i = 0 ; i < t2.length ; i = i+1 ) { Ecran.afficher(t2[i]," "); } Ecran.sautDeLigne(); } }