集册 Java实例教程 演示方法隐藏的测试类

演示方法隐藏的测试类

欢马劈雪     最近更新时间:2020-01-02 10:19:05

507
演示方法隐藏的测试类

class MySuper {

  public static void print() {

    System.out.println("Inside MHidingSuper.print()");       
    /* from 
    nowjava.com*/

  }

}

 class MySub extends MySuper {

  public static void print() {

    System.out.println("Inside MHidingSub.print()");  

  }

}

public class Main {

  public static void main(String[] args) {

    MySuper mhSuper = new MySub();

    MySub mhSub = new MySub();


    System.out.println("#1");


    MySuper.print();

    mhSuper.print();/** 时 代 J a v a 提供 **/


    System.out.println("#2");


    MySub.print();
展开阅读全文