public static void main(String[] args) {
int[] arr = {1,2,3,4,5};
for (int j = 0; j < arr.length; j++){
System.out.print(arr[j]+" ");
}
}可以用foreach遍历数组遍历
public static void main(String[] args) {
int[] arr = {1,2,3,4,5};
for (int anArr : arr) {
System.out.print(anArr + " ");
}
|
|