| Author |
Method Local Inner Class
|
Phal Ach
Ranch Hand
Joined: May 09, 2008
Posts: 54
|
|
Hi. Below is from geekevaluation.com, regarding method local inner class. I know that final variables of methods can only be accessed by its method local inner class. Then why not in below mentioned code? Here 'a' is a final variable. Still at Line 4, there is a compiler error. Somebody please give me a proper explanation for this. Thanks.
|
 |
Ralph Jaus
Ranch Hand
Joined: Apr 27, 2008
Posts: 342
|
|
There are two mistakes: 1. Within a class definition only declarations of variables, methods, blocks, etc. are allowed, but no statements like "a = 19;". The follwing example will help: 2. You can't assign a value to a final variable within a local class. The following would work: [ July 08, 2008: Message edited by: Ralph Jaus ]
|
SCJP 5 (98%) - SCBCD 5 (98%)
|
 |
Phal Ach
Ranch Hand
Joined: May 09, 2008
Posts: 54
|
|
|
Looks good Ralph. Thanks
|
 |
 |
|
|
subject: Method Local Inner Class
|
|
|