Java數組的初始化賦值有以下幾種方法:
int[] arr = {1, 2, 3, 4, 5};
int[] arr = new int[5];
for (int i = 0; i < arr.length; i++) {
arr[i] = i + 1;
}
int[] arr = new int[5];
Arrays.fill(arr, 10);
int[] arr1 = {1, 2, 3, 4, 5};
int[] arr2 = Arrays.copyOf(arr1, arr1.length);