Manipulation des listes dans des multimap en java
Salut tout le monde,
j'ai un petit souci dans la manipulation des multimap en java. Voila le code que j ai écris :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| Multimap<Float, List<String>> big = HashMultimap.create();
List<String> list1 = new ArrayList<String>();
list1.add("A");
list1.add("B");
list1.add("C");
System.out.println("List before " + list1);
big.put(0f, list1);
list1.remove(2);
big.put(0f, list1);
System.out.println("List after " + list1);
for(Entry<Float, Collection<List<String>>> entry : big.asMap().entrySet()) {
Float number = entry.getKey();
Collection<List<String>> strings = entry.getValue();
for(List<String> string : strings) {
System.out.println("Key " + number + " Value " + string);
}
} |
Voila, au lieu de me retourner :
Citation:
key 0.0 Value [A, B,C]
key 0.0 Value [A, B]
il me retourne toujours la même liste (celle après le remove) :
Citation:
key 0.0 Value [A, B]
key 0.0 Value [A, B]
Est ce qu il y a quelque chose qui m'échappe ?
Merci de votre aide.