码迷,mamicode.com
首页 > 编程语言 > 详细

java的多态

时间:2015-08-06 20:02:22      阅读:113      评论:0      收藏:0      [点我收藏+]

标签:

public class Fu {
    String num = "fu";
    static String  age ="fu static";
    void show() {
        System.out.println("fu  show  ");
    }

    static void method() {
        System.out.println("fu  static  method ");
    }
}


public class Zi extends  Fu {
    String num = "zi";
    static String  age ="zi static";
    void show() {
        System.out.println("zi  show  ");
    }

    static void method() {
        System.out.println("zi  static  method ");
    }
    public static void main(String[] args) {
        Fu f =new  Zi();
        System.out.println(f.num);
        System.out.println(f.age);
        f.show();
        f.method();
        
    }
    
}

-----------------------------------------------------------------------------------------------------------------

运行结果

fu
fu static
zi  show 
fu  static  method

java的多态

标签:

原文地址:http://www.cnblogs.com/52hadoop/p/4708802.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!