关于覆盖和隐藏的问题
public class planet{
public static void hide(){
System.out.println("The hide method in Planet.");
}
public void override(){
System.out.println("The override method in Planet.");
}
}
public class earth extends planet{
public static void hide(){
System.out.println("The hide method in Earth.");
}
public void override(){
System.out.println("The override method in Earth.");
}
pubilc ststic void main (String[] args){
Earth myEarth=new Earth();
Planet myPlanet=(Planet)myEarth;
myPlanet.hide();
myPlanet.override();
}
}
输出
the hide method in Planet.
The override method in Earth.
是怎么得来的,哪一句是控制输出的?
myPlanet.hide();
myPlanet.override();
这两句能说说什么意思嘛?