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

1 回答 1

3

很可能您使用的 JDK 版本低于 7。它不知道菱形<>是什么。

更改为以下内容将解决该问题:

new ArrayList<String>(listOfAcctStorageRuleName.size());

当然,您可以免费下载更新的 Java 版本以使用以前不允许的所有便捷功能。

于 2016-11-14T07:25:27.713 回答