Java之数组遍历
1 package basic; 2 //数组遍历方法 3 public class ForEach { 4 5 public static void main(String[] args) { 6 // 原始数组 7 String strs[] = { "a", "b", "c", "d" }; 8 9 // 数组输出常规方法 10 for (int x = 0; x < strs.length; x++) { 11 System.out.print(strs[x] + "、"); 12 } 13 System.out.println(" "); 14 // foreach输出-遍历数组 15 for (String s : strs) { 16 System.out.print(s + "、"); 17 } 18 } 19 20 }