日期:2014-05-20 浏览次数:20857 次
public class work2 {
public static void main(String[] args){
father A=new father();
son C=new son();
System.out.println("A="+C.f());
}
}
class father{
int i=1;
public int f(){
if(i==4)
return 0;
System.out.println(i+++"father");
return f();
}
}
class son extends father{
static int j=1;
public int f(){
System.out.println(j+++"son="+super.f());
return 0;
}
}
public class work2 {
public static void main(String[] args){
// father A=new father(); delete
son C=new son();
System.out.println("A="+C.f());
}
}
class father{
int i=1;
public int f(){
if(i==4)
return 0;
System.out.println(i+++"father");
return f();//这里做递归调用 f()调用的 是son里面的 f()
}
}
class son extends father{
static int j=1;
public int f(){
System.out.println(j+++"son="+super.f());
return 0;
}
}