Hi, I have confusion that if declare a variable or object refernce as final then where they reside. As I was going through Inner classes topic and its like if declare variable as final Inner clas is able to access but not normal variable.
Compiling the preceding code really upsets the compiler: MyOuter2.java:8: local variable z is accessed from within inner class; needs to be declared final System.out.println("Local variable z is " + z); ^ Can any one exaplein why it is so? Thanks in advance
SCJP1.5(81%), SCDJWS(94%), next mission SCEA (but need to wait or that)
Any local variable, formal method parameter or exception handler parameter used but not declared in an inner class must be declared final. Any local variable, used but not declared in an inner class must be definitely assigned (�16) before the body of the inner class.
method local inner classes have access to member variables of the enclosing class.. if a local variable needs to be used it should be declared final....try writing a small program...if your into software ...you will find it used as part of IBatis ORM mapping tool usage...
Achievements are like fire flies, there is no point clinging on to them as they are not visible the next day morning.