• Post Reply Bookmark Topic Watch Topic
  • New Topic

Static class  RSS feed

 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi

its about static class

does the static class make all its member(not declared static) static implicitly?
 
Sheriff
Posts: 11338
177
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No! It behaves like any other top-level class (but it has been nested in another top-level class for packaging convenience).

(As far as I know static classes are not on the OCAJP7, so moving to "Beginning Java" forum)
 
ssiva raman
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what do you mean by top-level classes?
i see that in lot of texts.
 
Ranch Hand
Posts: 262
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ssiva raman wrote:what do you mean by top-level classes?
i see that in lot of texts.


We will take that question. Let us first see how to code a static class that you have a question on.

So how about you code a static class and get it to compile? Post your code here.
 
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
recent thread

Its complicated, but in general the static keyword takes on a different (but not completely unrelated) meaning when used for static inner classes.

A top-level class is supposedly just a class that isn't a nested class.*


*not sure if one should count the second class in a file as a "top-level class" even if it isn't nested.
 
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tyson Lindner wrote:
A top-level class is supposedly just a class that isn't a nested class.*


*not sure if one should count the second class in a file as a "top-level class" even if it isn't nested.



The JLS (http://docs.oracle.com/javase/specs/jls/se7/html/jls-7.html#jls-7.6) defines a top level class, as a class that is not a nested, local, or anonymous class. So, I guess the second class in the file, that is not nested, is a top level class.

Henry
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!