Ankur kothari wrote:
why does not compile whereas this does?
Ankur kothari wrote:
just by adding final has changed evrything why? does final make x scope longer?
can determine if the instance of the inner class can make a copy of the value -- a value that will not changed, once initialized.
Ankur kothari wrote:
can determine if the instance of the inner class can make a copy of the value -- a value that will not changed, once initialized.
could not understand this?
SCJP 6
SCJP 6
Ankur kothari wrote:compiler simply says that i need to make x final...so be it....this goes down as a rule
SCJP 6
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.
scjp 1.6 91%, preparing for scmad
"Time to get MAD now.. we will get even later"....by someone unknown
how is initilizing at the declaration time right?
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
"Half of the science is to ask question"
scjp 1.6 91%, preparing for scmad
"Time to get MAD now.. we will get even later"....by someone unknown
Rizvan Asgarov wrote:Good explanation by the father of the inner class...
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Not looking good. I think this might be the end. Wait! Is that a tiny ad?
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
|