1、遍历循环
for (循环变量类型 循环变量名称;循环条件;更新语句) 循环体
String[] arr = { "a", "b", "c", "d" }; for (int i = 0; i < arr.length; i++) { System.out.println(arr[i]);
2、迭代器循环
String[] arr = { "a", "b", "c", "d" }; List<String> list = Arrays.asList(arr); for (Iterator<String> iterator = list.iterator();iterator.hasNext();) System.out.println(iterator.next());
3、增强型for循环
for (循环变量类型 循环变量名称 : 要被遍历的对象) 循环体
String[] arr = { "a", "b", "c", "d" };
|