• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Static class in java

 
Greenhorn
Posts: 25
Hibernate Eclipse IDE
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Oracle Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic