日期:2014-05-20  浏览次数:20623 次

为什么编译的时候,总提示: 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={

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