declare « enum « Java Data Type Q&A

1. Is there a way to declare an annotation attribute for *any* enum?

At the moment I am developing an annotation-based binding-framework for Java Swing that uses JGoodies Binding under the hood. Unfortunately I am stuck with an annotation for a JRadioButton-binding. What ...

2. Declare enum variable in Java bean

I need to declare an enum variable as a class member and need to define a setter and getter for that like a java bean. something like this -

public class Vehicle ...

3. doubt in enum declaration

can i make my enum private or protected. for ex

enum day{sun,mon,tue};
this is what we usually give. Can i give like
private enum day{mon,..};

4. What is the drawback of having more instances of enum type other than in the enum declaration?

It is a compile-time error to attempt to explicitly instantiate an enum type (ยง15.9.1). The final clone method in Enum ensures that enum constants can never be cloned, and the special treatment ...

5. Is it OK/possible to modify instance variables inside an enum declaration?

Or, to re-phrase it: can enum types be "mutable"?

public enum Foo {

    private String bar;

    Foo() { = ""; }

6. How can I declare enums using java

Good day! I want to convert this sample C# code into a java code:

public enum myEnum
        ONE = "one",

8. Enum Declaration

Hello All, I'm a first time poster, long time browser, hoping for clarification on enum declarations. In prep exams I'm taking before I sit for the SCJA, questions regrading enums are coming up that are leaving me a little confused. To be specific, it is all about the semi-colon. In one question the correct answer given for an enum declaration is ...

9. enum - fianl and local declaration

10. enum declaration in a method

Constants of interfaces and enums are always implicitly static. So when we have nested interfaces or enums then they are also implicitly static because static types can only be declared in static or top level types. Interfaces and enums are very much similar in this context. There are no non-static member, local, or anonymous interfaces or enums and both can be ...

11. enum declaration within inteface

Hi All, i have one inteface with common declaration of function and constant. now i want to declared enum within interface so classes which implemented this interface can easily access that enum. like public inteface ABC { int temp1; int temp2; enum Color { RED, GREEN, BLACK } } but i got error for this enum. Please help me Thanks, Nil ...