
{filelink=4727}
import java.util.Arrays;
public class InverArray {
/*
* La fonction 'inverser' reçoit un tableau comme
* paramètre elle inverse le contenu du tableau
* et retourne le résultat sous forme d'un nouveau tableau
*/
public static Object[] inverser(Object[] array)
{
if (array == null) {
return null;
}
int i = 0;
int j = array.length - 1;
Object tmp;
while (j > i) {
tmp = array[j];
array[j] = array[i];
array[i] = tmp;
j--;
i++;
}
return array;
}
public static void main (String[] argv)
{
Integer tab1[]= {1, 2, 3, 4, 5, 5};
System.out.println ("Contenu Originl? "+Arrays.toString(tab1));
System.out.println ("Contenu inversé? "+Arrays.toString(inverser(tab1)));
}
}