This question has been asked here earlier too. But i did not find it helpful.
It is just based on an assumption. please throw some insight on this.
Asked
Active
Viewed 2,327 times
1

dexterousashish
- 373
- 1
- 4
- 18
-
5Perhaps you are assuming the answer should be more complex than it is. top level classes are already effectively static. – Peter Lawrey Sep 28 '13 at 03:38
-
1[Get in touch with your inner class](http://www.javaranch.com/campfire/StoryInner.jsp) – Edwin Dalorzo Sep 28 '13 at 03:42
-
It is 'just based' on *what* 'assumption'? What are you talking about? – user207421 Sep 28 '13 at 04:15
2 Answers
8
static
classes means there is no reference to an instance of an outer class.
Top level classes cannot have a reference to an outer class, so in a way they are all static classes.
The reason you can't make them static, is there is no other option and the syntax for top level classes was determined before there was a option for nested classes.

Peter Lawrey
- 525,659
- 79
- 751
- 1,130
-
I don't see what 'the syntax for outer classes ...' has to do with it. 'static' wouldn't add anything so it isn't legal. – user207421 Sep 28 '13 at 04:13
-
@EJP there are many situations where redundant modifiers are allowed. All nested `enum` are static, and adding it as a modifier is allowed. – Peter Lawrey Sep 28 '13 at 04:49
-
No. Incorrect. "static" means there is no reference to an **instance** of an outer class. – Dawood ibn Kareem Sep 28 '13 at 05:10
-
I see you've made an edit to that first sentence, so +1 now. – Dawood ibn Kareem Sep 28 '13 at 20:26
2
Your question doesn't mean anything. Whether an inner class is static or not basically means, is an instance of that inner class associated with a particular instance of the outer class. If a class is not an inner class, it doesn't mean anything to say that it's static or not static.

Dawood ibn Kareem
- 77,785
- 15
- 98
- 110