[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [jdt-core-dev] New for loop
|
Only in 1.5 branch.
Olivier Thomann
<Olivier_Thomann@
ca.ibm.com> To
Sent by: jdt-core-dev@xxxxxxxxxxx
jdt-core-dev-admi cc
n@xxxxxxxxxxx
Subject
[jdt-core-dev] New for loop
04/01/2004 05:02
PM
Please respond to
jdt-core-dev
The enhanced for statement (foreach) is now supported. We still need to do
more testing, but the implementation is in place.
We can successfully compile:
import java.util.ArrayList;
public class X {
public static void main(String[] args) {
ArrayList<Integer> arrayList = new ArrayList<Integer>();
for (int i = 0; i < 10; i++) {
arrayList.add(new Integer(i));
}
int sum = 0;
for (Integer e : arrayList) {
sum += e.intValue();
}
System.out.println(sum);
}
}
The result is: 45
We can also compile:
public class X {
public static void main(String[] args) {
int[] tab = new int[] {1, 2, 3, 4, 5, 6, 7 , 8, 9};
int sum = 0;
for (int e : tab) {
sum += e;
}
System.out.println(sum);
}
}
The result is still: 45
Olivier