下面创建数组的语句( )是正确的。
A: int a[5] = {1,2,3,4,5};
B: float f[10] = new float;
C: char ch[] = "abcd";
D: int n = 10; int[] a = new int[n];
A: int a[5] = {1,2,3,4,5};
B: float f[10] = new float;
C: char ch[] = "abcd";
D: int n = 10; int[] a = new int[n];
举一反三
- 以下数组定义符合Java语法的有? A: int a[10]; B: int n=5;int b[n]={1,2,3,4,5} C: int []c={1,2,3,4,5}; D: int d[]=new int[5]; E: int e[]=new int[]{1,2,3,4,5}; F: int e[]=new int{1,2,3,4,5};
- 创建数组正确的是: A: int[] ia = new int [15]; B: float fa = new float [20]; C: char[] ca = “Some String”; D: Object oa = new float[20]; E: Int ia [][] = (4, 5, 6) (1, 2, 3)
- 关于二维数组的创建,以下做法正确的是: (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 [] score =new int[]{1,2,3,4,5}; B: int [] score=new int[5]{1,2,3,4,5}; C: int [5] score=new int[]{1,2,3,4,5}; D: int [5] score=new int[5]{1,2,3,4,5};