数组遍历
数组遍历
public class Test1 {
public static void main(String[] args) {//数组遍历
int[] a = {27,94,39,76,32,64,83};
for (int i = 0; i < a.length; i++) {
System.out.println(a[i]);
}
System.out.println("====================================");
int i = 0;
while (i<a.length){
System.out.println(a[i]);
i++;
}
//for循环和while循环都能遍历数组,for循环更简洁
}
}
27
94
39
76
32
64
83
====================================
27
94
39
76
32
64
83
Process finished with exit code 0

浙公网安备 33010602011771号