已采納回答 / 小丶冬瓜
在使用中指定哪個就調用哪個,比如說例子中測試類調用了Train.move()方法,那么就是move()方法,如果Train類中還存在其他方法比如put()方法,那么則通過Train.put()調用。而proxy.invokeSuper(obj, args);中的args是指定在調用方法時可否帶參數。如果proxy.invokeSuper(obj);的話。在調用方法時是不可以帶參數的。
2018-02-25
已采納回答 / 窗下有梧桐
InvocationHandler invocationHandler2=new LogHandler(moveable);
Class<?> class2 = moveable.getClass();
Moveable moveable2 =(Moveable)Proxy.newProxyInstance(class2.getClassLoader(), class2.getInterfaces(), invocationHandler2);
moveable2.move();
2017-11-14