Why use static enum?

Sometimes I saw use static enum in android. but I can't find that information(I know enum in C) example,

   public static enum brush{
        static{
          array[0] = brush1;
          array[1] = brush2;
          array[2] = brush3;
          array[3] = brush4;
    }
}

but that is occurred error in project. error message is "Syntax error, insert "Identifier" to complete EnumConstantHeader" but I don't understand that's mean.

Jon Skeet
people
quotationmark

The problem is that this is an enum without a list of members. You'd normally have:

public enum Foo {
    VALUE1, VALUE2;
}

You can have an enum with no members, but you still need the semi-colon:

public enum Foo {
    ;
}

That's now valid, although not terribly useful.

The static part in the enum declaration is presumably because it's nested within another class. This isn't actually required - nested enum declarations are implicitly static.

The static { ... } is just a static initializer, run when the type is initialized.

Enums in Java are quite different from those in C. You should read the enum section on the Java tutorial for more details.

people

See more on this question at Stackoverflow