I am almost done with a calculation activity I am working with in android for my app. I try to create a Gender Enum, but for some reason getting Syntax error, insert “EnumBody” to complete EnumDeclaration.
public static enum Gender
{
static
{
Female = new Gender("Female", 1);
Gender[] arrayOfGender = new Gender[2];
arrayOfGender[0] = Male;
arrayOfGender[1] = Female;
ENUM$VALUES = arrayOfGender;
}
}
I have also tried it without the static {} but I get the same syntax error.
Where on earth did you find this syntax? Java Enums are very simple, you just specify the values.
If you want them to be more complex, you can add values to them like this.
Then to use the enum, you would do something like this: