Java动态代理
什么是动态代理 为什么要用动态代理 实战demo import java . lang . reflect . InvocationHandler ; import java . lang . reflect . Method ; import java . lang . reflect . Proxy ; public class ProxyTest { public static void main ( String [ ] args ) { UserServiceProxy userServiceProxy = new UserServiceProxy ( new UserServiceImpl ( ) ) ; UserService aaa = userServiceProxy . getInstance ( ) ; System . out . println ( aaa . getUserName ( ) ) ; System . out . println ( aaa . getUserAge ( ) ) ; } } interface UserService { String getUserName ( ) ; int getUserAge ( ) ; } class UserServiceImpl implements UserService {