• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Static member classes and intefaces

 
Ravinderjit Singh
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 9528
32
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Static inner classes can only be created within top level classes and static inner classes (not all static members)...
 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.. I got.....
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic