This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

final instance variables

 
sri yadagini
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If a final instance variable is not initialized, does it take the default value?
I am getting a compiler error when i am trying to execute the following code:




What i thought is-- the variable i will be printed as '0', the default value for int.
 
Aleksander Zielinski
Ranch Hand
Posts: 127
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Final variable must be initialized when being declared or in the constructor.
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Aleksander Zielinski:
Final variable must be initialized when being declared or in the constructor.

Or, in other words, by the time the constructor exits.
 
Junilu Lacar
Bartender
Pie
Posts: 6531
21
Java Linux Mac Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See the JLS �8.3.1.2
 
sri yadagini
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I appreciate for all the replies.I understood the concept.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic