[clos] collection java

Fermé
heronasro1 - 7 juin 2013 à 23:03
Twinuts Messages postés 5375 Date d'inscription dimanche 4 mai 2003 Statut Modérateur Dernière intervention 14 juin 2023 - 9 juin 2013 à 09:33
j'ai un probleme concerne l'affiche de cette programme ; ask qlq peut m'aider ;;; Urgent ^^


import java.util.Iterator;^^
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;

public class mss {
public static void main(String args[]) {
String texte = "salama salama salmatation saLama salama? aaa ????? aaa VA , §§§§§ 1 2 3 4 5 6 l'ecole la a Z aaa a a a a AA A SAlama";
String str = "" ;
Set set = new TreeSet();
List l = new LinkedList();
List ll = new LinkedList(); // pour l'occurence
// pour éliminer les vides et des certains caractères
char ilimin [] = {' ',';','!','?',',',':','\'','"'};

int a=1 ;
for (int f=0; f< texte.length(); f++) {
for(int j=0 ; j< ilimin.length && a==1 ; j++)
if (texte.charAt(f) == ilimin[j]) a=0;

if (a==1) {
str+=texte.charAt(f);
}
if (a==0) { // if (str!="" && str.length()> 2) le bute est de éliminer les str vide et str < 2 comme va, a, ...
if (str!="" && str.length()> 2) { l.add(str.toLowerCase()); } str=""; a=1;
}
}
l.add(str.toLowerCase()); // pour dernier str
for(int vv = 0; vv < l.size(); vv++) // le bute est ordonnée les caractères
{ set.add(l.get(vv));}
int d=0 , occ=0;
Object[] obj = set.toArray();

while (d < obj.length) {
for(int vv = 0; vv < l.size(); vv++){
if( obj[d]== l.get(vv)) occ++;
}
ll.add(occ) ; occ = 0; d++;


}

for(int v = 0; v < obj.length; v++){

System.out.println(obj[v]+" "+ll.get(v)); // pour affichage le résultat de tableau ordonnée et sa occurrence
}

}
}

resultat obtenu est : mais normalement j'attend sa
aaa 1 aaa 3
ecole 1 ecole 1
salama 1 salama 5
salmatation 1 salmatation 1
§§§§§ 1 §§§§§ 1

1 réponse

Twinuts Messages postés 5375 Date d'inscription dimanche 4 mai 2003 Statut Modérateur Dernière intervention 14 juin 2023 111
9 juin 2013 à 09:33
Salut,

l'urgence est pour toi et en AUCUN CAS pour nous!

Sujet clos!


-----

"On n'est pas au resto : ici on ne fait pas dans les plats tout cuits ..."

OoWORAoO
0
Rejoignez-nous