Global Variable - Java: No Explicit Globals

Java: No Explicit Globals

Some languages, like Java, don't have global variables. In Java, all variables that are not local variables are fields of a class. Hence all variables are in the scope of either a class or a method. In Java, static fields (aka class variables) exist independently of any instances of the class and one copy is shared among all instances; hence static fields are used for many of the same purposes as global variables in other languages because of their similar "sharing" behavior.

Read more about this topic:  Global Variable

Famous quotes containing the word explicit:

    Like dreaming, reading performs the prodigious task of carrying us off to other worlds. But reading is not dreaming because books, unlike dreams, are subject to our will: they envelop us in alternative realities only because we give them explicit permission to do so. Books are the dreams we would most like to have, and, like dreams, they have the power to change consciousness, turning sadness to laughter and anxious introspection to the relaxed contemplation of some other time and place.
    Victor Null, South African educator, psychologist. Lost in a Book: The Psychology of Reading for Pleasure, introduction, Yale University Press (1988)