Java中輸出整個數組的方法有以下幾種:
int[] arr = {1, 2, 3, 4, 5};
System.out.println(Arrays.toString(arr));
int[] arr = {1, 2, 3, 4, 5};
for (int i = 0; i < arr.length; i++) {
System.out.print(arr[i] + " ");
}
System.out.println();
int[] arr = {1, 2, 3, 4, 5};
for (int num : arr) {
System.out.print(num + " ");
}
System.out.println();