Danilo sent us an interesting Java-Quiz from the Java Specialists’ Newsletter created by Olivier Croisier. You have to insert your corrective code in place of the //FIXME
comment, following these instructions:
- Do not modify his existing code, it’s Perfect (of course).
- The FIXME tag shows where you’re allowed to insert your corrective code
- He must be able to understand your solution when he comes back (so using Reflection is not an option).
Can you find a solution for it?
final List<String> list = new ArrayList() {{ add("Hello"); }}; final Iterator<String> iterator = list.iterator(); System.out.println(iterator.next()); list.add("World"); // FIXME : work here while I'm sunbathing System.out.println(iterator.next());
Later I’ll post my attempt to solve it.