代理对象 商家 public interface IIBM { public void sell(); } public class IBM implements IIBM{ public void sell() { System.out.println("sell a goods !"); } } public static void main(String[] args) { IIBM i =(IIBM) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[]{IIBM.class}, new InvocationHandler() { public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { IIBM i = new IBM(); System.out.println("sss ."); i.sell(); return i; } }); i.sell(); } 转载于:https://my.oschina.net/u/2296689/blog/545753 来源: https://blog.csdn.net/chuoxieai9700/article