Only 48 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



  • Post Reply Bookmark Topic Watch Topic
  • New Topic

static final vars  RSS feed

 
Vinay Gangoli
Greenhorn
Posts: 22
  • 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
  • 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.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!