Re: public static final - compilation error



> Hi,
>
> is it possible to initialize a public static final member of a class in
> the class' constructor? I try to do this and I receive error message:
>
> variable PLUS is declared final; cannot be assigned.
>

<snip>

I would suggest using an enum with a string embedded in each instance if you
are running Java 1.5
--Paul


.



Relevant Pages

  • no default constructor -- bad form?
    ... question (which a C++ question, not a windows question), but the class ... and to make an sense the class must know what the member is. ... But this puts me in the position of having no default constructor, ... I have to initialize x_ to something meaningful when ...
    (comp.lang.cpp)
  • Member Initialization Gotcha!
    ... This only took a few hours to figure out after I finally went back to MSDN and saw this warning regarding member initialization: ... So you would think that two protected const DWORD members shown here would be constructed in its declared order: ... Well, never mind the above uses D1 to initialize D2, the above is drastically reduce code for illustration. ... It showed up when the original constructor: ...
    (microsoft.public.vc.language)
  • Re: Best practice and is there a difference?
    ... classes and not classes where the constructor takes arguments. ... private String string1 = String.Empty; ... I go ahead and initialize them where it is ... In the above case, while I create the list at the member declaration, I ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Arrays!
    ... > innitialize a two dimensional array in my constructor of my class. ... you declare and initialize a local variable named ... There is no syntax in C++ to initialize an array that is a member ...
    (microsoft.public.vc.language)
  • Re: public static final - compilation error
    ... > is it possible to initialize a public static final member of a class in ... > the class' constructor? ... in which you can initialize your members. ... Prev by Date: ...
    (comp.lang.java.help)