nadimlegend
Messages postés9Date d'inscriptiondimanche 11 mai 2008StatutMembreDernière intervention27 mars 2009
-
23 mars 2009 à 20:22
nadimlegend
Messages postés9Date d'inscriptiondimanche 11 mai 2008StatutMembreDernière intervention27 mars 2009
-
27 mars 2009 à 21:05
slt mes freres j'ai un grand probleme
j'ai un tableau de chaine de caracteres et je peux pas calculer les elements differents de mon tableau SVP à l'aide
MahaYassine
Messages postés31Date d'inscriptionmercredi 26 mars 2008StatutMembreDernière intervention 4 février 2010 27 mars 2009 à 14:39
voila a pau près ce ke jé compris !! dis moi si c bon ou pas !
bon pour remplir le tableau dan la partie main jé mi du nimporte koi !!
public class Main {
public static void eliminerDoublons(String[] tab) {
for (int i = 0; i < tab.length; i++) {
if (tab[i] != null) {
for (int j = 0; j < tab.length; j++) {
if (tab[j]!= null && tab[i].equals(tab[j]) && i != j) {
tab[j] = null;
}
}
}
}
}
public static void affiche(String[] tab) {
for (int i = 0; i < tab.length; i++) {
if (tab[i] != null) {
System.out.println(tab[i]);
}
}
}
public static void main(String[] args) {
// TODO code application logic here
String tab[] = new String[100];
Integer j = 0;
for (int i = 0; i < tab.length; i++) {
tab[i] = j.toString();
j++;
if (j == 10) {
j = 0;
}
}
eliminerDoublons(tab);
affiche(tab);
}
}