This week's book / license giveaways are in the JDBC and Relational Databases and Java in General forums.
We're giving away four copies each of PostGIS in Action and Java Advanced Topics Training and have the authors on-line!
See this thread and this one for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes local inner class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "local inner class" Watch "local inner class" New topic
Author

local inner class

Anne Sullivan
Greenhorn

Joined: Mar 29, 2007
Posts: 9
Does a local inner class which resides inside a static method still have the "can only access local variables that is declared final" restriction?
Priyam Srivastava
Ranch Hand

Joined: Oct 29, 2006
Posts: 169
yes whether the class is declared in a static or a non static method, it can only access local variables that are marked final..


when you compile this code it gives an error like::


Test.java:8: local variable b is accessed from within inner class; needs to be declared final
System.out.println("b = " + b);
^
1 error


"History would be kind to me, for I intend to write it."
Deepak Jain
Ranch Hand

Joined: Aug 05, 2006
Posts: 637
Someone deleted my reply


SCJP, SCWCD, SCBCD
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: local inner class