Collection Proxy2=(Collection)Proxy.newProxyInstance(Collection.class.getClassLoader(),
new Class[]{Collection.class},
new InvocationHandler(){
ArrayList<String> al=null;
// al=new ArrayList<String>();//在代理里面这样分行是不让写的?????????????
public Object invoke(Object proxy, Method method, Object[] args)
throws Throwable {
if(al==null) //
al=new ArrayList<String>();//但是这样有是让写的呢???
Object retru=method.invoke(al, args);
return retru;
}
});
|