zoukankan      html  css  js  c++  java
  • 17、Java 三大特性之 多态

    java使 使

    1

    2

    class Animal{
       public int month = 2;
       public void eat(){
           System.out.println("西");
      }

    }

    class Dog extends Animal{
       public int month = 3;

       public void eat() {
           System.out.println("");
      }

       public void sleep() {
           System.out.println("");
      }
    }

    class Cat extends Animal{
       public int month = 4;

       public void eat() {
           System.out.println("");
      }
    }

    public class Test {
       public static void main(String[] args){
           Animal a = new Dog();
           Animal b = new Cat();
           a.eat();
           System.out.println(a.month);
           //
    //       a.sleep();
           b.eat();
           System.out.println(b.month);

      }
    }

    aAnimalDog;

    bAnimalCat

    eatAnimaleat


    2

    2

    maina.sleep()aAnimalAnimalsleepsleep

    a,bmonth,2

    3java

    Java

    3.1.

     

    3.2.

     

     

    4

    1.:

    2.:   

    3.:[]

    4.:使  

    5.:[]

    5

       访使使

        


                    

    圈~

     注公众号

  • 相关阅读:
    css添加方法
    node + vue 实现服务端单向推送消息,利用EventSource
    获取公众号openid,通过unionid 和小程序用户绑定起来
    小程序 构建npm
    powershell禁止系统运行脚本
    mongoose 删除
    mongoose 查询
    moogoose 更新
    小程序,用户授权手机号,node需要检验和解析
    小程序:支付的时候缺少参数:total_fee,支付失败
  • 原文地址:https://www.cnblogs.com/naimao/p/13353322.html
Copyright © 2011-2022 走看看