File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

static final vars

 
Vinay Gangoli
Greenhorn
Posts: 22
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Anupam Sinha
Ranch Hand
Posts: 1090
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic