首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java相关 >

为什么编译的时候,总提示: Test8.java:13: 异常: 需要'}' }; ^ 1 个异常

2012-12-18 
为什么编译的时候,总提示: Test8.java:13: 错误: 需要'}' } ^ 1 个错误class Test8 {public st

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

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

热点排行