comportement boucle for bizarre
Bonjour à tous,
Voici mon souci :
J'ai :
- 1 ArrayList<Integer> tabSetSource : [0,1,2,3,4,...]
- 1 ArrayList<Integer> tabSource : [0,0,0,0,0,0,1,1,1,1,1,2,2,2,2,2,3,3,3,3,3,4,4,4,4,4,...]
- 1 ArrayList<String> tabMot qui correspond à tabSource : [mot0,mot1,mot2,mot3,mot4,...]
Je veux afficher les mots en fonction du tabSetSource et je fais :
Code:
1 2 3 4 5 6 7 8 9 10
|
for (int i = 0; i < tabSetSource.size(); i++) {
System.out.println("la source " + tabSetSource.get(i) + " a les mots suivants : ");
for (int j = 0; j < tabSource.size(); j++) {
if (tabSource.get(j) == tabSetSource.get(i)) {
System.out.print(tabMot.get(j) + "|");
}
}
System.out.println();
} |
Cela m'affiche très bien les mots des 127 premières sources. Puis cela ne m'affiche qu'1 seul mot par source !!! Je n'y comprends rien !!!
Merci de vos réponses !!
@+