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:

    ... the Ovarian Theory of Literature, or, rather, its complement, the Testicular Theory. A recent camp follower ... of this explicit theory is ... Norman Mailer, who has attributed his own gift, and the literary gift in general, solely and directly to the possession of a specific pair of organs. One writes with these organs, Mailer has said ... and I have always wondered with what shade of ink he manages to do it.
    Cynthia Ozick (b. 1928)