java for循环就是,对于某些操作,人为地控制循环次数。最简单的,比如打印数字。
举例:打印 0 ~ 100
for (int i = 1; i <= 100; i++) {
System.out.println(i);
}
int[] a = new int[]{1,2,3,4,5,6,7,8,9,10,11,12};
for(int iloop : a){
System.out.println(iloop);
}
/* 建立一个Collection */
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);
}