当前位置: 技术问答>java相关
请问怎么初始化一个二维String数组?
来源: 互联网 发布时间:2015-08-14
本文导语: 我写成 String[2][2] strArray= {{"一","二"},{"三","四"}}; 提示错误: javax.servlet.ServletException: Compilation error occured: Found 3 errors in JSP file: Syntax: "AssignmentOperator AssignmentExpression" inserted to complete Assignment Syntax: ";" in...
我写成
String[2][2] strArray= {{"一","二"},{"三","四"}};
提示错误:
javax.servlet.ServletException: Compilation error occured:
Found 3 errors in JSP file:
Syntax: "AssignmentOperator AssignmentExpression" inserted to complete Assignment
Syntax: ";" inserted to complete ExpressionStatement
Syntax: Invalid ArrayType
请问这样的数组初始化该怎么写,谢谢!
String[2][2] strArray= {{"一","二"},{"三","四"}};
提示错误:
javax.servlet.ServletException: Compilation error occured:
Found 3 errors in JSP file:
Syntax: "AssignmentOperator AssignmentExpression" inserted to complete Assignment
Syntax: ";" inserted to complete ExpressionStatement
Syntax: Invalid ArrayType
请问这样的数组初始化该怎么写,谢谢!
|
String[][] str = {{"a","b"},{"c","d"}};
|
String[] s=new String[2][2]
赋值
赋值
|
String[][] strArray = {{"一","二"},{"三","四"}};
或:
String strArray[][] = {{"一","二"},{"三","四"}};
或:
String strArray[][] = {{"一","二"},{"三","四"}};
|
String[][] strArray = new String[2][2];
strArray[0][0] = "一";
strArray[0][1] = "三";
strArray[1][0] = "二";
strArray[1][1] = "四";
strArray[0][0] = "一";
strArray[0][1] = "三";
strArray[1][0] = "二";
strArray[1][1] = "四";