-
Enhancement
-
Resolution: Fixed
-
P3
-
1.3.0
-
tiger
-
generic
-
generic
Name: krT82822 Date: 10/12/99
I believe that having foreach functionality in the Java Language
would be an excellent addition. This is easy to explain and
understand, so I will be brief.
Here is some sample code of mine:
Iterator paneIter= contentLists.keySet().iterator();
while(paneIter.hasNext()) {
String paneName= (String) paneIter.next();
//... loop body, maybe just one line
}
I would like for 'each' functionality so that this can reduce to:
for(String paneName, contentLists.keySet()) {
//... loop body (no braces necessary if just one line)
}
Basically, what the compiler does is understand that the second
parameter to the for() construct is a Collection. Knowing
what a Collection is, it gets the iterator, and can produce in
a very straight forward way, the bytecode for the loop for the
code I first wrote.
10/12/99 eval1127@eng -- see also # 4183241
(Review ID: 96439)
======================================================================
I believe that having foreach functionality in the Java Language
would be an excellent addition. This is easy to explain and
understand, so I will be brief.
Here is some sample code of mine:
Iterator paneIter= contentLists.keySet().iterator();
while(paneIter.hasNext()) {
String paneName= (String) paneIter.next();
//... loop body, maybe just one line
}
I would like for 'each' functionality so that this can reduce to:
for(String paneName, contentLists.keySet()) {
//... loop body (no braces necessary if just one line)
}
Basically, what the compiler does is understand that the second
parameter to the for() construct is a Collection. Knowing
what a Collection is, it gets the iterator, and can produce in
a very straight forward way, the bytecode for the loop for the
code I first wrote.
10/12/99 eval1127@eng -- see also # 4183241
(Review ID: 96439)
======================================================================