A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

© 谭荣强 高级黑马   /  2014-6-11 23:36  /  819 人查看  /  0 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

new ProxyInstance()返回值是什么?为什么ArrayList的代理类返回值写ArrayLsit不行,写List就可以
List proxydemo = (List)Proxy.newProxyInstance(
                                ArrayList.class.getClassLoader(),
                                ArrayList.class.getInterfaces(),
                                new InvocationHandler() {                                         
                                        public Object invoke(Object proxy, Method method, Object[] args)
                                                        throws Throwable {                                                 
                                                ArrayList list = new ArrayList();
                                                Object retvalue = method.invoke(list, args);                                         
                                                return retvalue;
                                        }
                                }
                                );

0 个回复

您需要登录后才可以回帖 登录 | 加入黑马