1
當我創建一個加載時,我的程序給出了以下錯誤;關於我的代碼的非法啓動類型錯誤
D:\views\UniqueAcctStorageRuleNameValidator.java:34: illegal start of type
List<String> listOfAcctStorageRuleNameAsArray =
new ArrayList<>(listOfAcctStorageRuleName.size());
這是代碼;
public class FKAcctStorageRuleNameValidator extends AbstractAnnotationCheck<FKAcctStorageRuleName>{
private static final long serialVersionUID = 1L;
private SpecbookValidatorManager specBookValidator;
@Override
public boolean isSatisfied(Object validatedObject, Object valueToValidate,
OValContext context, Validator validator) throws OValException {
if (valueToValidate == null) return true;
specBookValidator = SpecbookValidatorManagerImpl.getInstance();
List<SpecbookAcctStorageRule> listOfAcctStorageRuleName = specBookValidator.getAcctStorageRuleList();
List<String> listOfAcctStorageRuleNameAsArray = new ArrayList<>(listOfAcctStorageRuleName.size());
for (SpecbookAcctStorageRule specbookAcctStorageRule : listOfAcctStorageRuleName) {
listOfAcctStorageRuleNameAsArray.add(specbookAcctStorageRule.getName());
}
return ListUtil.containsIgnoreCase((String) valueToValidate, listOfAcctStorageRuleNameAsArray);
}
}
哪個jdk是你用的? Java SE 7及更高版本,您可以使用鑽石<> ..請檢查您的java編譯器版本。 – iMBMT
你創建一個'ArrayList' * what *? Java中的泛型不需要類型? –
@iMBMT我正在使用Java SE 6.當我給鑽石參數時,問題就解決了。謝謝你的幫助。 – kaydemir