if i have two SEPERATE programs run (aka. different class to the JVM of public class) and they both use a static class/class member will they see the same values or is static just static within a single program running?
Printable View
if i have two SEPERATE programs run (aka. different class to the JVM of public class) and they both use a static class/class member will they see the same values or is static just static within a single program running?
I'm pretty sure its static within the program.
Otherwise you could have all sorts of problems if you had your variable named the same as one in another program that was running.
Buf if a Static member is available without creating an instance of a class, in CaptainPinko's example, the two classes would not be using any instance of the static class or the class having the static member, instead they would just be using whatever is there. How would the JVM track two different values for the static member?Quote:
Originally posted by Mrs Kensington
I'm pretty sure its static within the program.
Otherwise you could have all sorts of problems if you had your variable named the same as one in another program that was running.
.
I agree with Mrs Kensington.
I'm pretty sure that "two SEPERATE programs run - CaptainPinko", means two separate JVM's are running. What does "aka. different class to the JVM of public class" mean?
"How would the JVM... - honeybee", again I believe it would have to be that the single instance of a JVM would be keeping track of whatever was invoked by that invocation of "java SomeClass". A second invocation of "java SomeClass" or "java DifferentClass" should be in different memory spaces.