Originally posted by Gareth Leachman:
An explanation that I could offer is to think:
A static object can be references by any instance of this class.
I don't know what you mean by this.
But the static object is only created once and we can use it to keep track of state of the class, or the number of instantiations made.
Salman's question pertained to "static objects". You created a static primitive. Clearly the primitive will hold its same value accross different instances of the 'teststatic' class, but 'i' is not an object.
In terms of the original question... I believe you are referring to inner classes with the 'static' modifier, but I'm not sure what you mean with 'static object
created at class level'.
Do you want to elaborate.. I don't quite understand.
ps. You could check a possibly related
question I just posted:
[ December 17, 2003: Message edited by: Jim Crawford ]