我想制作二维数组并稍后解析它:
String[][] position = new String[3][3];
position = [{id:10, x:10, y:20}, {id:5, x:30, y:40}, {id:2, x:2, y:7},];
和
String[][] position = [
{id:10, x:10, y:20},
{id:5, x:30, y:40},
{id:2, x:2, y:7},
];
但是这两个都不能工作..
对我做错了什么有什么建议吗?
最佳答案
第一个字符串不是 int,字符串应该在 ""
之间,你的分配应该是这样的:
String[][] position =
{{"id:10", "x:10", "y:20"}, {"id:5", "x:30", "y:40"}, {"2", "2", "7"}};
如果您指的是 int 数组,您的数组应如下所示:
int[][] position = {{10, 10, 20}, {5, 30, 40}, {2, 2, 7}};
关于java - 实例化二维数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43862905/