java - Is it safe to assume that a static variable always exists -


this question has answer here:

in java i've seen class variables (defined keyword static) equivalent of global variables in other languages such c, defined inside class avoid name conflicts. in c can refer global variable function @ time exists while program running.

what static variables in java. exist? loaded when they're referred? wanna know if it's safe when use static variable static method of class.

also static variable ever destroyed?

a static variable initialized when class initialized, , valid (initialization of classes , interfaces).

initialization of class consists of executing static initializers , initializers static fields (class variables) declared in class.

if value of static field changed, , there no other references previous value, previous value garbage collected. however, reference exist, if "safe" means "never access illegal memory", safe (when using java language in general, not in case).


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -