File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Mock Exam Errata and the fly likes local inner classes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Mock Exam Errata
Bookmark "local inner classes" Watch "local inner classes" New topic

local inner classes

Akhil Gupta

Joined: Apr 22, 2001
Posts: 6
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
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.
Jyotsna Umesh
Ranch Hand

Joined: May 09, 2001
Posts: 94
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?
Jyotsna Umesh
Prakshi Chopra

Joined: Mar 05, 2001
Posts: 10
Dear Akhil
if you declare inner class inside a static method using static modifier compiler will give error.
I agree. Here's the link:
subject: local inner classes
It's not a secret anymore!