Given what I know of every other type of static feature of programming––I would think the answer is 'no'. However, seeing statements like OuterClass.StaticNestedClass nestedObject = new OuterClass.StaticNestedClass();
makes me wonder.
views:
100answers:
3Thanks! When I first think about it as I described in my comments on my question, my thought was "whatever is static is singular despite the enclosing context's instance". Now as I carefully consider your definition of 'static', I am re-defining my understanding of the term to be "whatever is static exists independently of the enclosing context's instance"––thus, a static nested class exists apart from an instance of it's parent class. And I believe this understanding of it would apply to static in the context of loop variables, function variables, and class members.
stormin986
2010-04-27 08:28:15
And the more I think about it: relating the idea of 'singular' to 'static' is a subtle error to make. The only reason loop variables, function variables, and class fields were occurring to me as singular is because they are declarative statements, NOT type definition statements. Thus, a static class is the only thing (immediately coming to mind, at least) that is both static and able to be used to define new objects.
stormin986
2010-04-27 08:34:34
@stormin986: maybe ask another question, "What does `static` mean?".
polygenelubricants
2010-04-27 08:56:04
A:
Yeah you can make instances of it as many times as you want.
Maybe the reason why you see that, is because the programme thought about storing a reference somewhere. Though i agree with you seems strange :S
fmsf
2010-04-27 07:58:09
A:
It is legal. The fact that the inner class is static gives you a benefit here; its instances are not bound to any instance of the containing class, so they can be freely instantiated (as long as the access qualifier allows it).
The price, however, is that the inner class can't use non static members/methods of the containing class.
Eyal Schneider
2010-04-27 07:59:04