This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Java Rule Round-up  RSS feed

 
Arnaldo Rossini
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The question 201 says "TRUE or FALSE: Member (instance) variables are always assigned a default value if not explicitly initialized. My answer was FALSE, Javaranch answer was TRUE.
I think that final variables are not assigned a dafault value, then member variables are not ALWAYS assigned a dafault value.
Maybe they are constants, and should not be called variables.
What do you think?
Bye
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From The JLS 4.5.3 Kinds of Variables
If a class T has a field a that is an instance variable, then a new instance variable a is created and initialized to a default value (�4.5.5) as part of each newly created object

If you declare a final variable and do not initialize it at that point it is refered to as a blank final. Of course the compiler will not allow you to leave it that way, but you can postpone the initialization until a constructor is executed for example.
[ October 01, 2002: Message edited by: Cindy Glass ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!