1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
HashMap<Integer, Set<Character>> setA;
HashMap<Integer, Set<Character>> setB;
setA = new HashMap<Integer, Set<Character>>();
setB = new HashMap<Integer, Set<Character>>();
Set<Character> s1 = new HashSet<Character>();
Set<Character> s2 = new HashSet<Character>();
s1.add('a');s1.add('b');s1.add('y');
s2.add('c');s2.add('d');s2.add('z');
setA.put(1, s1);
setB.put(2, s2);
System.out.println(setA.get(1));
System.out.println(setB.get(2));
setA.putAll(setB); //il remplace tout le contenu et pas l'union => non !
System.out.println(setA.get(1));
System.out.println(setA.get(2)); |