This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Mock Exam Errata
Bookmark "local inner classes" Watch "local inner classes" New topic
Author

local inner classes

Akhil Gupta
Greenhorn

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.
Regards,
Manfred.
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?
Regards
Jyotsna Umesh
Prakshi Chopra
Greenhorn

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: http://aspose.com/file-tools
 
subject: local inner classes
 
Similar Threads
new SCJP in town :)
Use of Inner classes
Inner Classes
Inner class
answer please