aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes static final vars Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "static final vars" Watch "static final vars" New topic
Author

static final vars

Vinay Gangoli
Greenhorn

Joined: Jun 13, 2003
Posts: 22
Hi all,
1) I believe a member variable ( say int) that is declared as final has to be initialized in a initializer block or a constructor. Is that right?

2) Can i do the same with a member variable declared as static final ?
This must be pretty common, but i am kinda confused abt it ...please comment on it. Thanks in advance


SCJP 1.4<br />" Somedays ur the dog...other days ur the water hydrant "
Anupam Sinha
Ranch Hand

Joined: Apr 13, 2003
Posts: 1088
Hi Vinay
A non-static final member variable has to be intialized at the place it is declared or in a constructor or a nonstatic intializer.
In case of a static final intializer the variable has to be intialized at the place it is declared or in a static intializer.
Hope this thread helps you.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: static final vars