While you are explaining this, i have a question. What does transient mean? And I''m also not quite sure about protected.
Thanks..
Java-->Global Variables--> ???
Variables marked as transient are not saved when serialising a class, so are usually volatile or calculated from the other data (such as the length of a list).
Protected vars are only accessible to the owning class and any inherited classes.
Protected vars are only accessible to the owning class and any inherited classes.
99 times out of 100, when you think you "need" global access to a single variable, you should re-think your design methodology, not try to force it to happen.
The best advice for global OBJECTS would be to use Singletons.
The best advice for global OBJECTS would be to use Singletons.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement