下面声明和创建数组的语句错误的是( )
A: int[] a=new int[12];
B: int[] c;c=new int[12];
C: int[] n={1,2,3,4,5};
D: int[] array = new int[3] {1,2};
A: int[] a=new int[12];
B: int[] c;c=new int[12];
C: int[] n={1,2,3,4,5};
D: int[] array = new int[3] {1,2};
举一反三
- 关于二维数组的创建,以下做法正确的是: (1)int a[][] =new int[4][5] (2)int a[][] =new int[4][]; a[0]=new int[10];a[1]=new int[20]; (3)int a[][]; a=new int[3][]; a[0]=new int[3]; a[1]={1,2};a[2]={1,2,3};
- 下面几条定义一维数组的语句,正确的是 A: int[] arr2 = new int[]; B: int[] arr2 = new int[5]; C: int arr2[] = new int[5]{1, 2, 3, 4, 5}; D: int[] arr2 = new int[5]{1, 2, 3, 4, 5, 6};
- 下列数组初始化正确的是:() A: int[5] a= {1,2,3,4,5}; B: int[2][2] a = {{1,2},{3,4}}; C: int[][] a = {{2,3,4,5},new int[3]}; D: int[][] a = new int[][5];
- 下面正确创建了二维交错数组的是()。 A: int[][] Arr=new int[3][];Arr[0]=new int[]{10,20,30};Arr[1]=new int[]{40,50,60,70};Arr[2]=new int[]{80,90}; B: int[,] Arr=new int[3,];Arr[0]=new int[]{10,20,30};Arr[1]=new int[]{40,50,60,70};Arr[2]=new int[]{80,90}; C: int[][3] Arr={new int[]{10,20,30},new int[]{40,50,60,70},new int[]{80,90}}; D: int[3][] Arr={new int[3]{10,20,30},new int[4]{40,50,60,70},new int[2]{80,90}};
- 下列关于数组的语句,错误的是: A: int x[];x=new int[5]; B: double[] y[];y=new double[2][3]; C: int x[3]={1,2,3}; D: int y[][]=new int[2][];y[0]=new int[3];y[1]=new int[5];