zoukankan      html  css  js  c++  java
  • java 静态代理

    interface clothFactory{
        void productCloth();
    }
    
    class NikeClothFactory implements clothFactory{
    
        @Override
        public void productCloth() {
            System.out.println("Nike生产了衣服");
        }
    }
    
    
    class ProxyClothFactory implements clothFactory{
        NikeClothFactory nc;
    
        public ProxyClothFactory (NikeClothFactory obj){
            this.nc=obj;
        }
    
        @Override
        public void productCloth() {
            System.out.println("通过了静态代理");
             nc.productCloth();
    
        }
    }
    
    
    public class TestStaticProxy {
    
        public static void main(String[] args) {
            NikeClothFactory  nf1 = new NikeClothFactory();
            nf1.productCloth();
    
            ProxyClothFactory nf2 = new ProxyClothFactory(nf1);
            nf2.productCloth();
    
        }
    }
  • 相关阅读:
    AC自动机学习笔记(模板)
    codeforces1328E
    Codeforces 1288E- Messenger Simulator (树状数组)
    线性基小记
    HDU3949
    矩阵快速幂小记
    5E
    5D
    5C
    5B
  • 原文地址:https://www.cnblogs.com/MagicAsa/p/11745844.html
Copyright © 2011-2022 走看看