我想創建一個類的動態數組傳遞給可變參數。這可能嗎?如果沒有,動態創建一個普通的類數組的最佳方法是什麼?下面的代碼給出了下面的錯誤。如何將類的動態數組傳遞給可變參數?
代碼 -
private void validate(Validator vt, Object form, BindingResult errors, Class<?>... c){
vt.validate(form, c);
}
private void validate(Type type, BindingResult errors){
Validator vt = new Validator();
List groups = new ArrayList();
if(form.isAvailable()){
groups.add(Available.class);
}
if(form.isNotAvailable()){
groups.add(NotAvailable.class);
}
if(groups.size()>0){
validate(vt, form, errors, groups.toArray());
}
}
錯誤 -
The method validate(Validator, Object, BindingResult, Class<?>...) is not applicable for the arguments (Validator, Field, BindingResult, Object[])
你是怎麼稱呼它的? – 2011-05-17 18:03:20