以下给数组赋值的语句正确的是()
A: int[] number ; number = {1,2,3,4,5};
B: int[] number = {1,2,3,4,5};
C: int[] number = new int[5]; number[5] = 5;
D: int[] number = new int[5]; number = 5;
A: int[] number ; number = {1,2,3,4,5};
B: int[] number = {1,2,3,4,5};
C: int[] number = new int[5]; number[5] = 5;
D: int[] number = new int[5]; number = 5;
举一反三
- 下面几条定义一维数组的语句,正确的是 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};
- 对于如下关于随机数的代码 for(int number = 0; number != 5; number = (int)(Math.random() * 10)) { System.out.println(number); } 以下描述正确的是( )(2分)
- 以下数组定义,正确的是( )。 A: int a[5]; B: int[] a = new [5]; C: int[] a = {1, 2, 3, 4, 5}; D: int a = new int[5];
- 以下( )代码,不能够对数组正确初始化(或者是默认初始化)。 A: int[] a; B: int[] a = new int[5]; C: int[] a = new int[5]{1, 2, 3, 4, 5}; D: int[] a = {1, 2, 3, 4, 5};
- 下列关于数组的静态初始化语句,正确的是( ) 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};