zoukankan      html  css  js  c++  java
  • 第一次靠自己把java内存图画好还是挺有成就感的,虽然有老师帮助.第一次发,勿喷.....

    Client.class

    public class Client{
        public static void main(String[] args){
            Person p = new Person();
            Dog d = new Dog();
            Cat c = new Cat();
            
            p.feed(d);
            p.feed(c);


        }
    }

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

    Person.class

    public class Person{
        // 养狗
        public void feed(Dog d){
            d.eat();
        }
        
        // 养猫
        public void feed(Cat c){
            c.eat();
        }
       
       
        }

        //养别的
        
    }

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

    Dog.class

    public class Dog {
        //Method
        public void eat(){
            System.out.println( "狗吃肉" );
        }
    }

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

    Cat.class

    public class {
        //Method
        public void eat(){
            System.out.println( "猫吃鱼" );
        }

    }

  • 相关阅读:
    vue报错 error: data.push is not a function
    vue elment.style样式修改(第三方组件自生成元素)
    按元素标签查询多个
    按css查询多个元素
    按CSS查询一个元素
    查询单个元素
    JavaScript 查找元素
    Spring 商品分类
    Spring 使用日志
    Spring 使用日期类型
  • 原文地址:https://www.cnblogs.com/lwxalxy/p/4364207.html
Copyright © 2011-2022 走看看