interface Function{
void f(int a);
}
class BackRun implements Function{
public void f(int a){
System.out.println("对前台回应:" + a*a);
}
}
public class Proxy implements Function{
private BackRun backRun;
public Proxy(){
if(backRun == null)
backRun = new BackRun();
}
public void f(int a){
System.out.println("开始连接网络连接..");
System.out.println("连接成功,处理后台方法");
backRun.f(a); //完成代理的使用
}
}
class ForeRun{
public static void main(String[] args) {
int a = 3;
Function x = new Proxy();
x.f(a);
}
}