I am trying to use sets in the following way:
static Set<String> languages = new HashSet<String>();
languages.add("en");
languages.add("de");
And I get the following error message generated by Eclipse:
> Multiple markers at this line
> - Syntax error on token ""en"", delete this token
> - Syntax error on token(s), misplaced construct(s)
I cannot figure out what I am doing wrong. Can anybody please help me?
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.
.
"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:
You are doing something illegal:
Either this (if your code is at class level):
or this:
Instead, you could use a static initializer to initialize your set: