user3688530 user3688530 - 1 year ago 122
Java Question

illegal start of type error about my code

While I am creating a load , my program gives below error ;

D:\views\ illegal start of type
List<String> listOfAcctStorageRuleNameAsArray =
new ArrayList<>(listOfAcctStorageRuleName.size());

Here is the code;

public class FKAcctStorageRuleNameValidator extends AbstractAnnotationCheck<FKAcctStorageRuleName>{

private static final long serialVersionUID = 1L;

private SpecbookValidatorManager specBookValidator;

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) {

return ListUtil.containsIgnoreCase((String) valueToValidate, listOfAcctStorageRuleNameAsArray);

Answer Source

It’s likely that you are using the JDK a version which is lower than 7. It doesn't know what the diamond <> is.

Changing to the following will solve the issue:

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

Of course, you are free to download a newer Java version to use all convenient features that are not allowed in the previous ones.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download