I often see code like:
Iterator i = list.iterator(); while(i.hasNext()) { ... }
but I write that (when Java 1.5 isn\'t available or for
Why not use the for-each construct? (I haven't used Java in a while, but this exists in C# and I'm pretty sure Java 1.5 has this too):
List names = new ArrayList(); names.add("a"); names.add("b"); names.add("c"); for (String name : names) System.out.println(name.charAt(0));