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;
}
}
); |
|