以下正确声明可包含5个整型元素数组的代码是( )
A: int nums[5] = new int[];
B: int[] nums = new int[5];
C: int[] nums = new int{5};
D: int[5] nums = new int[];
A: int nums[5] = new int[];
B: int[] nums = new int[5];
C: int[] nums = new int{5};
D: int[5] nums = new int[];
举一反三
- 下面定义创建数组的代码正确的是? A: int[5] nums = new int[]; B: int[] nums ={2,3,4,5}; C: int[] nums = new int[]{2,3,4,5}; D: int[] nums;nums={2,3,5,6};
- 以下数组的声明方式错误的是( ) A: int[] nums={1,2,3} B: int[] nums=new int[3] C: int nums[]={1,2,3} D: int[] nums = new int[3]{1,2,3}
- 下列数组初始化语句哪些是正确的 A: int[] nums = new int[]{0,1,2,3,4}; B: int[] nums2 = {0,1,2,3,4,5}; C: int[][] num_1 = {new int[]{0,1},new int[]{0,1,2},new int[]{0,1,2,3}}; D: int[][] num_2 = {{0,1},{0,1,2},{0,1,2,3}};
- 下列数组初始化语句哪些是正确的 A: int[] nums = new int[]{0,1,2,3,4}; B: int[] nums2 = {0,1,2,3,4,5}; C: int[][] num_1 = {new int[]{0,1},new int[]{0,1,2},new int[]{0,1,2,3}}; D: int[][] num_2 = {{0,1},{0,1,2},{0,1,2,3}};
- 下列数组初始化语句哪些是正确的 A: int[] nums = new int[]{0,1,2,3,4}; B: int[] nums2 = {0,1,2,3,4,5}; C: int[][] num_1 = {new int[]{0,1},new int[]{0,1,2},new int[]{0,1,2,3}}; D: int[][] num_2 = {{0,1},{0,1,2},{0,1,2,3}};