Start from Java 5, Java has for each feature
Collection c
for (Object o : c){
}
The above is equivalent to
for (Iterator i = c.iterator(); i.hasNext(); ) {
}
If you don't use Java 5, use the following to replace C# foreach statement.
while (! collection.isEmpty()) {
Object o = collection.get();
collection.next();
...
}
for (int i = 0; i < array.length; i++){
...
}
|