Pessoas,
caem questões de implementação de Collections na prova, como a abaixo? Ou cai somente questões como as do livro da Kathy?
1. import java.util.*;
2. public class DoorKeys {
3. int handles = 0;
4. public static void printAll(Collection c) {
5. Iterator it = c.iterator();
6. while (it.hasNext())
7. System.out.print (it.next() + " ");
8. }
9. public DoorKeys(int handles) {
10. this.handles = handles;
11. }
12. public String toString () {
13. return “[” + this.handles + “]”;
14. }
15. public static void main(String[] args) {
16. Map hm = new HashMap();
17. hm.put(new Integer(1),new DoorKeys(1));
18. hm.put(new Integer(1),new DoorKeys(2));
19. Collection s = hm.values();
20. DoorKeys.printAll((Collection)s);
21. }
22. }