JavaReview-day08-多态

多态

多态的特点

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
class Fu
{
//  int num = 3;
    void show()
    {
        System.out.println("fu show");
    }

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

class Zi extends Fu
{
//  int num = 4;
    void show()
    {
        System.out.println("zi show");
    }

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



class  DuoTaiDemo3
{
    public static void main(String[] args)
    {
        Fu.method();
        Zi.method();
        Fu f = new Zi();//
//      f.method();
//      f.show();
//      System.out.println(f.num);


//      Zi z = new Zi();
//      System.out.println(z.num);
    }
}
Licensed under CC BY-NC-SA 4.0
最后更新于 Apr 10, 2022 01:45 CST
Built with Hugo
主题 StackJimmy 设计