This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes final variable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply locked New topic

final variable

Raju Champaklal
Ranch Hand

Joined: Dec 10, 2009
Posts: 521
If you use final keyword then you are bound to initialize that variable at declaration time, this behavior guarantees that when class Inner will use x, x will have some value, so it can copy that value to s.

If you do not use final then there is no guarantee that when inner class will use x, x will have any value.

how is this right?

final int x;

is legal then how is initilizing at the declaration time right?

this was from one of the previous posts of Punit.....

scjp 1.6 91%, preparing for scmad
"Time to get MAD now.. we will get even later" someone unknown
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 60810

Please continue any discussion n that topic.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
wood burning stoves
subject: final variable
Similar Threads
Inner class Compile Time Constant
Inner Class Question
Pl Validate the points
what is the reason?
regarding blank final