Re: Problem with Eclipse and Enum's



On 21 Apr 2005 18:15:28 -0700, MrFredBloggs@xxxxxxxxxxx wrote:

>I tried the following and it worked.
>
>public enum Days
>{
> SUNDAY(1),
> MONDAY,
> TUESDAY,
> WEDNESDAY,
> THURSDAY,
> FRIDAY,
> SATURDAY;
> private Days() {}
> private Days(int i) {}
>}
>
>It uses private constructors though, according to Eclipse, public ones
>aren't allowed (is that correct, must they always be private?).
>
>Fankx for the help,
>
>Fred.
To start off, Eclipse didn't seem to care that the constructors were
public or private, not sure if that matters or not.

I don't know the answer to my following question, but I am taking a
guess based upon the example implementation.

Enums in Java seem as though they don't have a particular value. For
example Days.SUNDAY doesn't equal 1. I may be wrong and hope if
someone else has a better information they will post it. They appear
to be more complicated than the C++ cousines.

I am not sure if this implementation with empty constructor calls is
really what you have in mind.

Just thinking out loud.
--Steve

.



Relevant Pages

  • Re: Problem with Eclipse and Enums
    ... >>It uses private constructors though, according to Eclipse, public ones ... must they always be private?). ... >Enums in Java seem as though they don't have a particular value. ...
    (comp.lang.java.programmer)
  • Re: Types of constructors
    ... Private mUID As String ... Private Sub New ... the function had full access to the new object's private member fields. ... : What are the other kinds of constructors besides: ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Highlight Constructors in Eclipse ?
    ... In Eclipse 3.2.1 you can go to menu Window/Preferences ... constructors so there may not be a direct way to get what you want. ... Java/Appearance/Member Sort Order, however, you can specify that your ... margin indicator and the syntax coloring for constructors. ...
    (comp.lang.java.help)
  • Re: Eclipse, getters and setters
    ... But the two "instance variables" were private final which meant that I could not create setters for them and have the code compile. ... I understand why final private variables can't have setters, but I would have thought that Eclipse was smart enough to tell me I was trying to do something illegal when it started to fulfill my request. ... private final int cadence = 0; ...
    (comp.lang.java.help)
  • Re: Xml serialization problem
    ... public enum ValuesB ... private ValuesB v2; ... > I try to serialize this class with XmlSerializer without success ...
    (microsoft.public.dotnet.languages.csharp)