下列关于Java数组的代码片段,错误的是( )。
A: int[] a=new int[20];
B: String[] names = new String[3];
C: String[] names = {"Bob", "Achebe", null};
D: int[5] ages = new int[];
A: int[] a=new int[20];
B: String[] names = new String[3];
C: String[] names = {"Bob", "Achebe", null};
D: int[5] ages = new int[];
举一反三
- 下列定义字符串数组的语法正确的是( )? A: String[] list = new String[]{"red", "yellow", "green"}; B: String list = new String{"red", "yellow", "green"}; C: String list = {"red", "yellow", "green"}; D: String[] list = {"red", "yellow", "green"};
- 定义并初始化一个用于存放我们国家的四个直辖市的数组cityName,四个直辖市为:北京,上海,天津,重庆. 正确的是_________ A: String[] cityName=new String[4]{"北京","上海","天津","重庆"}; B: String[] cityName=new String[]{"北京","上海","天津","重庆"}; C: String[] cityName={"北京","上海","天津","重庆"}; D: String cityName = new String[4] { "北京", "上海", "天津", "重庆" };
- 下列数组定义正确的是( )。 A: int[] a[]= new float[2]; B: byte b[][]=new byte[3][]; C: String[] str=new String[3]; D: int my[][]=new int[3][3];
- 下列哪个选项能正确的创建数组?( ) A: int[,] array = int[4,5]; B: int size = 2;int[] pins = new int [size]; C: string[] str = new string[]; D: int pins[] = new int[2];
- 下列哪个选项能正确的创建数组?( ) A: int[,] array=int[4,5]; B: int size=int.Parse(Console.ReadLine()); int[] pins=new int [size]; C: string[] str=new string[]; D: int pins[] = new int[2];