java中for循环的三种写法
(2012-02-06 14:04:15)
int[] integers = {1, 2, 3, 4};
for (int j = 0; j < integers.length; j++) {
int i = integers[j];
System.out.println(i);
}
String[] strings = {"A", "B", "C", "D"};
Collection stringList = java.util.Arrays.asList(strings);
for (Iterator itr = stringList.iterator(); itr.hasNext();) {
Object str = itr.next();
System.out.println(str);
}
int[] integers = {1, 2, 3, 4};
for (int i : integers) {
System.out.println(i);
} |
|