Re: public static final - compilation error
- From: Roedy Green <look-on@xxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 29 Aug 2005 07:11:04 GMT
On Tue, 28 Jun 2005 17:59:12 +0200, Thomas Fritsch
<i.dont.like.spam@xxxxxxxxxxx> wrote or quoted :
>No, you can't initialize 'static final' things in a constructor or any
>non-static method. But you can (and probably want to) initialize them in
>the class initializer:
The reason is a constructor will be called many times, at least
potentially, but a static initialiser block is guaranteed to be called
exactly once.
Java does not want to deal with the possibility of you changing your
mind about a final value.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
.
- Prev by Date: Question about debugging .class file
- Next by Date: Re: I need a command line in Windows NT
- Previous by thread: Question about debugging .class file
- Next by thread: Re: I need a command line in Windows NT
- Index(es):
Relevant Pages
|