zoukankan      html  css  js  c++  java
  • java 类装饰

    package TestIo;
    
    public class Test8 {
        public static void main(String[] args) {
            System.out.println("未装饰前----------------");
            Python python = new Python();
            python.show();
            System.out.println("装饰后------------------");
            StrongCoder strongCoder = new StrongCoder(python);
            strongCoder.show();
        }
    }
    
    
    class Python {
        private String name;
    
        public void show() {
            System.out.println("我会写python程序");
        }
    }
    
    
    class StrongCoder {
        private Python p;
    
        public StrongCoder(Python p1) {
            p = p1;
        }
    
        public void show() {
            this.p.show();
            System.out.println("我不仅会写python,还写java");
        }
    }
    

      

  • 相关阅读:
    设计模式之中介者模式
    解释器模式(行为模式)
    进程池Pool
    Process子类
    multiprocessing
    random
    re
    time和datetime
    logging 日志
    hashlib
  • 原文地址:https://www.cnblogs.com/leigepython/p/9996581.html
Copyright © 2011-2022 走看看