• Post Reply Bookmark Topic Watch Topic
  • New Topic

Static class in java  RSS feed

 
Greenhorn
Posts: 25
Eclipse IDE Hibernate
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everybody,


I am preparing for SCJP1.6 and i had gone through the static inner classes and i have doubt does java support normal static java class .

I googled it , i came to know that there is no static class (normal class) in java.But what my doubt is why java doesn't support static class.
 
Ranch Hand
Posts: 79
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Ramesh
it is right that JAVA does not have static class
but i thing i would like to tell you that take inner class a a class method(just suppose)
as we cam have static method in a class then we can have a static inner class in a class
that is why inner class can be static because these inner classes are the member of class and member of class can be static
Hope you got my point :-)
 
Ranch Hand
Posts: 198
Java Linux Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
silamala ramesh babu wrote:Hi Everybody,
I googled it , i came to know that there is no static class (normal class) in java.But what my doubt is why java doesn't support static class.


I am just wondering what you will do with static class. I mean what are the extra/special feature that you require from a class to make it as static
 
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Top-level classes (classes that are not nested classes) cannot be made static.
silamala ramesh babu wrote:But what my doubt is why java doesn't support static class.

Suppose that it would be possible to make a top-level class static. What would you expect that that would mean? Java doesn't support it because it doesn't mean anything to make a top-level class static.
 
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
silamala ramesh babu wrote:
I googled it , i came to know that there is no static class (normal class) in java.But what my doubt is why java doesn't support static class.


Static means "associated with the defining class as a whole, rather than with individual instances of the defining class." Since a top-level class doesn't have a defining class (that is a class inside which it is declared), static makes no sense there.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!