0

I just learned about enums and am a bit confused. I want to declare my enums all in one File I found this question and for all I can see did exactly that

Multiple Enum Classes in one Java File

only that it does not work

public class DERstring{

public enum Fertigkeit 
{
    UEBER = "Überreden"; 
    HEIML = "Heimlichkeit"; 
    SUCHE = "Suchen";
}

public enum Terrain
{
    LEICHT = "leicht";
    MITTEL = "mittelschwer";
    UNPASS = "unpassierbar";
}
}

for each inner ennum class eclipse gives me the Error "insert 'EnumBody to complete ClassBodyDeclaration. What is it I'm doing wrong here?

3
  • clear/rebuild your project once. Commented Apr 14, 2014 at 10:35
  • 1
    You're defining enums in Java incorrectly, this needs to be a COMMA separated list of enumerated values and if you need an additional string value look here: stackoverflow.com/questions/1067352/… Commented Apr 14, 2014 at 10:35
  • Look below at Peter's answer. Commented Apr 14, 2014 at 10:38

1 Answer 1

1

You have incorrect syntax. Try something like this:

public class DERstring{

        public enum Fertigkeit 
        {
         UEBER("Überreden"), 
         HEIML("Heimlichkeit"),
         SUCHE("Suchen");

         private String name;

         private Fertigkeit(String name){
            this.name=name;
         }

         public String getName() {
            return name;
         }

    }

.....other enums classes...

}

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.