Hello all... Final Var in Local Class. Can someone tell me how in the below program can i access the Final Variable x (See Comment Line 6) class FinOuter { int w = 33; void met() { final int w = 45;// Line 6 class Local { int w = 55; void met() { System.out.println(w); // Prints 55 System.out.println(this.w); // Prints 55 System.out.println(FinOuter.this.w); // Prints 33 } } } } Thanks.
Shah Chunky - Sun Certified Java2 Programmer.
Thomas Paul
mister krabs
Ranch Hand
Joined: May 05, 2000
Posts: 13974
posted
0
Once you define a "w" in the inner class you lose reference to the final "w" in the met() method.