enums: static or not?

hello, i am working with enums a lot and all of them are like

public static enum SomeEnum { … }

it is also possible to leave the static away, but i cant think of a reason why this would make any sense.

can someone give an example where a non-static enum makes sense?

thanks!

Honestly, I didn’t think it made any difference. I can’t think of any reason not to make them static, but I’m surprised you can even do it.

I usually don’t use them as inner classes, so it doesn’t really apply to my code.

I think non-static enums can store some state, or variables. So there is a difference definetly!

http://java.sun.com/j2se/1.5.0/docs/guide/language/enums.html (Look at the Planet enum.)

But if you’re using your enums just for MyEnum.Something then I’d use static.

[quote]if an enum is a member of a class, it is implicitly static
[/quote]
See:
url]http://www.javapractices.com/Topic1.cjp[/url]

thanks all for your information!

It doesn’t make any difference. If you don’t use static, your enum is even static.