| Author |
final variable initialization
|
reubin haz
Ranch Hand
Joined: May 12, 2005
Posts: 287
|
|
Can someone explain why the compiler is complaining final variable might not being initialzed yet? thanks.
|
SCJA, SCJP5.0, SCBCD, SCWCD
|
 |
Srinivasa Raghavan
Ranch Hand
Joined: Sep 28, 2004
Posts: 1228
|
|
Final variables must be initialized either at the time of declaration or before the constructor of the class holding the final variable, completes. So in your code you are not initilizing the final variable in the constructor with ini param [ c(int i) ]. Hence the compiler error. [ June 28, 2005: Message edited by: Srinivasa Raghavan ]
|
Thanks & regards, Srini
MCP, SCJP-1.4, NCFM (Financial Markets), Oracle 9i - SQL ( 1Z0-007 ), ITIL Certified
|
 |
siva prakash
Ranch Hand
Joined: Aug 24, 2004
Posts: 80
|
|
Hi, value to final variable can be assigned at intialization block also ex :-- public class Test { final String st ; { st = "hello" ; } Test() { } } With Regards, Siva
|
 |
 |
|
|
subject: final variable initialization
|
|
|