class Father
{
int i;
void meth()
{
System.out.println("father");
}
}
class Son extends Father
{
void meth()
{
System.out.println("son");
}
}
public class Method {
public static void main(String[] args) {
Father f=new Son();
f.meth();
}
}
---------------------------------------------------------------------------
Father f=new Son(); 什么意识阿?
{
int i;
void meth()
{
System.out.println("father");
}
}
class Son extends Father
{
void meth()
{
System.out.println("son");
}
}
public class Method {
public static void main(String[] args) {
Father f=new Son();
f.meth();
}
}
---------------------------------------------------------------------------
Father f=new Son(); 什么意识阿?
那么Son就“是一个(is-a)”Father
就如同男人“是一个”人,而人不一定是男人
但人所具有的性质男人都有