Please can somebody tell me if we can declare inner classes with in a method to be static or private. If i compile it, it gives me a error, although error it shows is different, but is due to that only, whereas as Khalid-Mughal and marcus green exam 1 question no. 30 says so. Please help me about it
Manfred Leonhardt
Ranch Hand
Joined: Jan 09, 2001
Posts: 1492
posted
0
Hi Akhil, You must have missed it in KM book (page 238) Local classes can NOT have any accessibility specified. The class is defined as static or not depending on whether the method is static or not. For example, a local class defined in a static method will be considered static, while a local class defined in a non-static method will be considered non-static. Regards, Manfred.
Jyotsna Umesh
Ranch Hand
Joined: May 09, 2001
Posts: 94
posted
0
hi Manfred, Please explain that if local class in a staic method is defined as static though it is implicitly static becoz of the method being static), will it be wrong? Regards Jyotsna Umesh
Prakshi Chopra
Greenhorn
Joined: Mar 05, 2001
Posts: 10
posted
0
Dear Akhil if you declare inner class inside a static method using static modifier compiler will give error.