A DESCRIPTION OF THE REQUEST :
there is no reason that this shouldn't work:
String text = "whatever"
for (char c : text) { ... }
JUSTIFICATION :
this is exactly the reason that the 'foreach' construct was added - to simplify code where you're iterating over containers with similar values. it should be trivial to implement.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
the above syntax should work.
ACTUAL -
you need this more complex code:
String text = "whatever"
for (int i = 0, len = text.length(); i < len; i++) {
char c = text.charAt(i);
...
}
###@###.### 2005-05-24 05:21:23 GMT
there is no reason that this shouldn't work:
String text = "whatever"
for (char c : text) { ... }
JUSTIFICATION :
this is exactly the reason that the 'foreach' construct was added - to simplify code where you're iterating over containers with similar values. it should be trivial to implement.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
the above syntax should work.
ACTUAL -
you need this more complex code:
String text = "whatever"
for (int i = 0, len = text.length(); i < len; i++) {
char c = text.charAt(i);
...
}
###@###.### 2005-05-24 05:21:23 GMT
- duplicates
-
JDK-5003547 (str) add support for iterating over the codepoints in a string
-
- Closed
-