读书人

为什么编译的时候总提示: Test8.ja

发布时间: 2012-12-18 12:43:41 作者: rapoo

为什么编译的时候,总提示: Test8.java:13: 错误: 需要'}' }; ^ 1 个错误
class Test8
{
public static void main(String[] args)
{
int[][] map={
{{0,0,0,1,0,0,0},
{0,0,1,0,1,0,0},
{0,1,0,0,0,1,0},
{1,0,0,0,0,0,1},
{0,1,0,0,0,1,0},
{0,0,1,0,1,0,0},
{0,0,0,1,0,0,0}
};
for(int row=0;row<map.length;row++){
for(int col;col<map.length;col++){
switch(map[row][col]){
case 0:
System.out.print(' ');
break;
case 1:
System.out.print('*');
break;
}
System.out.println();
}
}
}
}

[最优解释]


class Test8
{
public static void main(String[] args)
{
int[][] map={{0,0,0,1,0,0,0},{0,0,1,0,1,0,0},{0,1,0,0,0,1,0},{1,0,0,0,0,0,1},{0,1,0,0,0,1,0},{0,0,1,0,1,0,0},{0,0,0,1,0,0,0}};
for(int row=0;row<map.length;row++){
for(int col=0;col<map.length;col++){
switch(map[row][col]){
case 0:
System.out.print(' ');
break;
case 1:
System.out.print('*');
break;
}
System.out.println();
}
}
}
}

[其他解释]
int[][] map={

这里的大括号,你没有匹配,后面明显少写了一个。
[其他解释]
是两个呀,最后头
引用:
int[][] map={

这里的大括号,你没有匹配,后面明显少写了一个。

[其他解释]
看到了,前面多了一个
引用:
int[][] map={

这里的大括号,你没有匹配,后面明显少写了一个。

读书人网 >Java相关

热点推荐