khaled001
Messages postés156Date d'inscriptionmardi 19 août 2008StatutMembreDernière intervention 8 août 2016
-
15 janv. 2012 à 17:26
cs_Julien39
Messages postés6414Date d'inscriptionmardi 8 mars 2005StatutModérateurDernière intervention29 juillet 2020
-
20 janv. 2012 à 07:53
Bonjour
voici mon code:
package leBonCompte;
public class leBonCompte {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int tableauDesEntiers[] = {3, 8, 9};
triTableau(tableauDesEntiers);
for(int i = 1; i <= tableauDesEntiers.length; i++)
{
System.out.print(tableauDesEntiers[i]);
}
}
public static void triTableau(int tab[])
{
int a;
for (int i = 1; i <= tab.length; i++ )
{
if(tab[i+1] > tab[i])
{
a = tab[i];
tab[i] = tab[i+1];
tab[i+1] = a;
}
}
}
}
Voila le resultat affiché apres execution :
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 3
at leBonCompte.leBonCompte.triTableau(leBonCompte.java:25)
at leBonCompte.leBonCompte.main(leBonCompte.java:11)
Quelqu'un peut il m'aider svp ?
Cordialement, spider17
PS: les lignes du code sont en ordre avec le résultats de l’exécution