Collection的代理类,照老师写的,总是报错,帮忙看看怎么回事- public static void main(String[] args) {
- Collection proxy = (Collection)Proxy.newProxyInstance(
- Collection.class.getClassLoader(),
- new Class[]{Collection.class},
- new InvocationHandler() {
- @Override
- public Object invoke(Object proxy, Method method, Object[] args)
- throws Throwable {
- Object retVal = method.invoke(proxy, args);
- return retVal;
- }
- }
- );
- proxy.add("lhm");
- }
复制代码 |