Java數組可以通過以下幾種方式進行初始化:
int[] arr = {1, 2, 3, 4, 5};
int[] arr = new int[5];
arr[0] = 1;
arr[1] = 2;
arr[2] = 3;
arr[3] = 4;
arr[4] = 5;
int[] arr = new int[5]; // 默認初始化為0
int[][] arr = {{1, 2, 3}, {4, 5, 6}};
int[] arr = new int[]{1, 2, 3, 4, 5};