je souhaiterais inverser un tableau et mettre le resultat dans nu autre tableau
j'ai l'erreur suivante a l'exécution
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 class tt { public static void main(String[] args) { int [] tab ={1,2,3,4,5,6,7,8,9}; int [] result=new int [9]; int k=9; for (int i=1;i<=10;i++) { result[i]=tab[k]; k--; } System.out.println(result); } }
merci--------------------Configuration: tt - JDK version 1.8.0_144 <Default> - <Default>--------------------
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 9
at tt.main(tt.java:19)
Process completed.
Partager