主题:高手请进!!!!
class Depend
{
int i=10;
public Depend()
{
print();
i=20;
}
void print()
{
System.out.println("Depend=>"+i);
}
}
public class Target extends Depend
{
int i=30 ;
public Target()
{
print();
super.print();
i=40 ;
}
void print()
{
System.out.println( "Target=>"+i);
}
public static void main(String[] args)
{
Target target=new Target();
System.out.println(target.i);
}
}
输出结果是
Target=>0
Target=>30
Depend=>20
40
谁能解释下
{
int i=10;
public Depend()
{
print();
i=20;
}
void print()
{
System.out.println("Depend=>"+i);
}
}
public class Target extends Depend
{
int i=30 ;
public Target()
{
print();
super.print();
i=40 ;
}
void print()
{
System.out.println( "Target=>"+i);
}
public static void main(String[] args)
{
Target target=new Target();
System.out.println(target.i);
}
}
输出结果是
Target=>0
Target=>30
Depend=>20
40
谁能解释下