What does the “Multiple markers” mean?

帅比萌擦擦* 提交于 2019-11-28 01:12:41

"Multiple markers" just means "there's more than one thing wrong with this line".

But the basic problem is that you're trying to insert statements directly into a class, rather than having them in a constructor, method, initializer etc.

I suggest you change your code to something like this:

static Set<String> languages = getDefaultLanguages();

private static Set<String> getDefaultLanguages()
{
    Set<String> ret = new HashSet<String>();
    ret.add("en");
    ret.add("de");
    return ret;
}

You are doing something illegal:

Either this (if your code is at class level):

// field definition on class level
static Set<String> languages = new HashSet<String>();
// statements are not allowed here, the following lines are illegal:
languages.add("en");
languages.add("de");

or this:

private void foo(){
    // static keyword not legal inside methods
    static Set<String> languages = new HashSet<String>();
    languages.add("en");
    languages.add("de");

}

Instead, you could use a static initializer to initialize your set:

static Set<String> languages = new HashSet<String>();
static{
  languages.add("en");
  languages.add("de");
}

This means on a single line you are getting multiple errors.

The pic below describes the best. Refer @Jon Skeet to know how to resolve these errors.

.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!