当前位置:编程学习 > JAVA >>

Java接口代理

package Proxy;
inte易做图ce MyInte易做图ce{
 void dosomething();
}
public class RealClass implements MyInte易做图ce{
 public void dosomething() {
  System.out.println("RealClass\tdosomething");
 }
}
class ProxyClass implements MyInte易做图ce{
 private MyInte易做图ce ins;
 public ProxyClass(MyInte易做图ce c){
  this.ins=c;
 }
 public void dosomething() {
  System.out.println("处理1");
  ins.dosomething();
  System.out.println("处理2");
 }
}
class T{
 public static void main(String[]abc)
 {
  ProxyClass c=new ProxyClass(new RealClass());
  c.dosomething();
 }
}
本文出自 “飞沙” 博客

补充:软件开发 , Java ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,