Iterator i = list.iterator();but I write that (when Java 1.5 isn't available) as:
while(i.hasNext()) {
...
}
for(Iterator i = list.iterator();i.hasNext();) {because
...
}
- It shorter
- It keeps i in a smaller scope
- It reduces the chance of confusion. (Is i used outside the while? Where is i declared?)
I think code should be as simple to understand as possible so that I only have to make complex code to do complex things. What do you think? Which is better?
No comments:
Post a Comment