Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

why top level classess can not be static

 
vikas karandikar
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why top level classess can not be static.
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you mean package member classes... because top-level (nested) classes are always static...
Static means that no instance of the enclosing class is needed to instantiate the enclosed class.
[ October 11, 2002: Message edited by: Valentin Crettaz ]
 
vikas karandikar
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are perfectly write my question was of regarding package member class.
We know that ,if method or variable is static that means it can be accessed without any referance of class.Moreover static variable belong to whole class etc
But what are the possible reasons for a entire class to be non-static.
In short my question is
"Why java does not allow to declare top level menber class as static?"
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It would be a good idea if you could read the following chapter of Mughal's book:
Chapter 7: Inner classes
The topic is very well explained there
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic