1、for循环的三种用法
1.1
1 int[] integers = {1, 2, 3, 4}; 2 for (int j = 0; j < integers.length; j++) { 3 int i = integers[j]; 4 System.out.println(i); 5 }
1.2
1 String[] strings = {"A", "B", "C", "D"}; 2 Collection stringList = java.util.Arrays.asList(strings); 3 for (Iterator itr = stringList.iterator(); itr.hasNext();) { 4 Object str = itr.next(); 5 System.out.println(str); 6 }
1.3
1 int[] integers = {1, 2, 3, 4}; 2 for (int i : integers) { 3 System.out.println(i); 4 }