public class Example04{
public static void main(String[] args){
final int SIZE=15;
for(int x=1;x<=SIZE;x++){
for(int y=1;y<=SIZE;y++){
int z=x*y;
if(z<10) System.out.println("");
if(z<10) System.out.println("");
System.out.println(""+z);
}
    System.out.println(""+z);
}
}
}D:\Java_Exercise\Example04.java:11: 找不到符号
符号: 变量 z
位置: 类 Example04
                    System.out.println(""+z);
                                          ^
1 错误

解决方案 »

  1.   

    System.out.println(""+z); 
    变量z超出作用范围
    建议修改成:
    if(z <10) System.out.print ("  ");  
    System.out.print(""+z); 

    System.out.println(); 
      

  2.   

    你用记事本写的吧,如果是IDE工具,直接就给你提示了,我把你的代码在eclipse中写了一下,你看看就知道了。public class Exemple04 {
    public static void main(String[] args) {
    final int SIZE = 15;
    for (int x = 1; x <= SIZE; x++) {
    for (int y = 1; y <= SIZE; y++) {
    int z = x * y;
    if (z < 10)
    System.out.println("");
    if (z < 10)
    System.out.println("");
    System.out.println("" + z);
    }
    System.out.println("" + z);
    }
    }
    }你第二次输出z时,已经不在z的作用域了。
      

  3.   

    你用记事本写的吧,如果是IDE工具,直接就给你提示了,我把你的代码在eclipse中写了一下,你看看就知道了。public class Exemple04 {
    public static void main(String[] args) {
    final int SIZE = 15;
    for (int x = 1; x <= SIZE; x++) {
    for (int y = 1; y <= SIZE; y++) {
    int z = x * y;
    if (z < 10)
    System.out.println("");
    if (z < 10)
    System.out.println("");
    System.out.println("" + z);
    }
    System.out.println("" + z);
    }
    }
    }你第二次输出z时,已经不在z的作用域了。