方法的隐藏与方法的覆盖的概念?
---------------------------------
你说的是什么意思?

解决方案 »

  1.   

    方法的隐藏是封装性,方法的覆盖是重载,也就是所谓的多态。
      

  2.   

    楼上的又在误导小朋友了!
    覆盖和重载完全是两码事!覆盖就是子类的方法跟父类的方法具有完全一样的签名和参数,而重载是签名相同参数不同,可以是同一个类也可以是子类跟父类!
    隐藏一般是对成员变量和静态方法来说的,网上的代码:
    class Planet {
    public static void hide() {
    System.out.println("The hide method in Planet.");
    } public void override() {
    System.out.println("The overrid 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.");
    } public static void main(String[] args) {
    Earth myEarth = new Earth();
    Planet myPlanet = (Planet) myEarth;
    myPlanet.hide();
    myPlanet.override();
    }
    }