java中错误的创建数组的方法是

2024-11-20 14:16:19
推荐回答(2个)
回答1:

错误的方法有很多,以下举几个简单的例子:String [] arrStr = new String();
String [] arrStr = new String[];
String [] arrStr = new String [] ();
String [] arrStr = new String {};
正确创建数组的方法:
String [] arrStr = new String [5];
String [] arrStr = new String[]{“a”};
String [] arrStr = {“a”};
String arrStr [] = new String [5];
String arrStr [] = new String[]{“a”};
String arrStr [] = {“a”};

回答2:

下面答案正确,我验证过