This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
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

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Static member classes and intefaces" Watch "Static member classes and intefaces" New topic

Static member classes and intefaces

Ravinderjit Singh
Ranch Hand

Joined: Jan 13, 2010
Posts: 78
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.

Ankit Garg

Joined: Aug 03, 2008
Posts: 9453

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%|
subject: Static member classes and intefaces
It's not a secret anymore!