标签:override 一个 package you vat stact after happy print
package demo01;
//静态代理,真实对象和代理对象都要实现同一个接口
public class StacticProxy {
public static void main(String[] args) {
You you=new You();
new Thread(()-> System.out.println("我爱你")).start();
new WweedingCompany(new You()).HappyMarry();
}
}
interface Marry{
void HappyMarry();
}
class You implements Marry{
@Override
public void HappyMarry() {
System.out.println("大帅要结婚了");
}
}
class WweedingCompany implements Marry{
private Marry marry;
public WweedingCompany(Marry marry) {
this.marry = marry;
}
@Override
public void HappyMarry() {
before();
this.marry.HappyMarry();
after();
}
private void after() {
System.out.println("婚后收礼");
}
private void before() {
System.out.println("婚前准备");
}
}
标签:override 一个 package you vat stact after happy print
原文地址:https://www.cnblogs.com/2506236179zhw/p/14315587.html