Re: enums



Is that "Input" an inner class by coincidence ? This would explain the error
msg, because you cannot do any static declaration in an inner class...

Best regards,
Jan

guyvo wrote:

> hi,
>
> I was glad to hear that v1.5 the enum class was introduced. I have a piece
> of code
>
> public class Input{
> public enum Condition {open,close}
> private Condition State;
>
> Input (Condition state){State = state;};
>
> protected void SetState (Condition state){State = state;};
> protected Condition GetState(){return State;};
>
>
> }
>
> The compiler gives me the following error :
>
> "enum declarations allowed only in static contexts"
>
> The enum in this example is just used as a type to my variable.
> What is wrong here?
> What purpose does it have than in respect to other langauges like C ?

--
______________________________________
insOMnia - We never sleep....
http://www.insomnia-hq.de
.



Relevant Pages

  • Re: Enums in inner classes
    ... > enum in a private final inner class, but I get the following message from ... Did you specify the -source 1.5 on the compiler command line? ...
    (comp.lang.java.programmer)
  • Re: A bafflement moment on enum
    ... Then I override the nextmethod with custom code in the various ... These methods live in anonymous inner classes of the enum (though ... The answer is that d contains a reference to the DALMATIAN inner class ... public void next ...
    (comp.lang.java.programmer)
  • Enums in inner classes
    ... enum in a private final inner class, but I get the following message from ... Any ideas which modifier it's got a problem with? ... private modifier and that has no effect. ...
    (comp.lang.java.programmer)
  • Re: Enums in inner classes
    ... >> enum in a private final inner class, but I get the following message from ... >> private modifier and that has no effect. ...
    (comp.lang.java.programmer)