Re: compiler question
- From: "John B. Matthews" <nospam@xxxxxxxxxx>
- Date: Sun, 29 Jun 2008 23:00:31 -0400
In article <48681888$0$14348$e4fe514c@xxxxxxxxxxxxxx>,
Maarten Bodewes <maarten.bodewes@xxxxxxxxx> wrote:
[...]
Yup, and to be sure that your variable will only be assigned precisely
once, create it using the final keyword.
final int thePrice;
if(..) thePrice = 1;
else thePrice = 2;
This will throw a compiler error whenever thePrice is not assigned, or
when thePrice is assigned a second time. Much more secure.
Aha, I had seen this in Roedy's and others' code without fully
understanding its import. I'm a fan of letting the compiler do the
work:-) Thanks!
[...]
--
John B. Matthews
trashgod at gmail dot com
home dot woh dot rr dot com slash jbmatthews
.
- References:
- compiler question
- From: ankur
- Re: compiler question
- From: Roedy Green
- Re: compiler question
- From: Maarten Bodewes
- compiler question
- Prev by Date: Re: Schema validation in production environment
- Next by Date: How to call a method in session bean from JSF (xhtml) page.
- Previous by thread: Re: compiler question
- Next by thread: Re: NewsMaestro Usenet Supertool v. 4.4.8 for Windows/Linux/Unix
- Index(es):