my dog learned polymorphism*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Static member classes and intefaces Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Static member classes and intefaces" Watch "Static member classes and intefaces" New topic
Author

Static member classes and intefaces

Ravinderjit Singh
Ranch Hand

Joined: Jan 13, 2010
Posts: 70
At page number 327 in Khalid Mughal's book
It is mentioned that
Static member classes and interfaces can only be nested within other static member or to level classes and interfaces


and i tried it as


but it is giving me compile time error and as per my understanding static dd() is a static member of class SuperA.

can anyone please clear my doubt or correct me.
Jehaan Butt
Ranch Hand

Joined: Feb 05, 2009
Posts: 41
The static class must be declared WITHIN a class but OUTSIDE a method/constructor/block. Similar to an enum, I believe. Try putting the static class outside the method. The compiler will be happy.


SCJP 6
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9291
    
  17

Static inner classes can only be created within top level classes and static inner classes (not all static members)...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Abimaran Kugathasan
Ranch Hand

Joined: Nov 04, 2009
Posts: 2066

Thanks.. I got.....


|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Static member classes and intefaces
 
Similar Threads
Anonymous Class
Inner classes in interfaces (how long has this been around?)
ClassCastException
Confused
Inheritance Doubt??