//楼主你好,我先给你举个最最经典的子父之间的例子,你懂的
class Fu
{
int num = 10;
void show()
{
System.out.println("Fu show");
}
static void method()
{
System.out.println("Fu static method");
}
}
class Zi extends Fu
{
int num = 20;
void show()
{
System.out.println("Zi show");
}
static void method()
{
System.out.println("Zi static method");
}
}
class DuoTaiDemo3
{
public static void main(String[] args)
{
Fu f = new Zi();
//用父类对象调用成员变量
System.out.println(f.num);
//用父类对象调用非静态方法
f.show();
//用父类对象调用静态方法
f.method();
}
}
/*
Fu f = new zi();
左边 右边