标题: 代码报错求解 [打印本页] 作者: xiaobaosdu 时间: 2016-6-12 22:05 标题: 代码报错求解 class test {
public static void main(String[] args) {
Zi z = new Zi();
}
}
class Fu {
int a = 1;
static {
System.out.println("静态代码块Fu");
}
{
System.out.println("构造代码块Fu");
System.out.println("构造代码块fu执行时c的值"+this.c);//这一句会报错“找不到符号”
}
public Fu() {
System.out.println("构造方法Fu");
System.out.println("构造方法fu执行时a的值"+this.a);
}
}
class Zi extends Fu {
int c = 3;
static {
System.out.println("静态代码块Zi");
}
{
System.out.println("构造代码块Zi");
System.out.println("构造代码块Zi执行时c的值"+this.c);
}
public Zi() {
System.out.println("构造方法Zi");
System.out.println("构造方法Zi执行时c的值"+this.c);
}
}