Why Does Java Not Support Global Variable?

1

1 Answers

Rinav Gangar Profile
Rinav Gangar answered
Java is Object Oriented Language. We talk about Classes and Objects in OOPS world.
The makers of Java are smart and Intelligent, they do not want any security loop holes due to global variables, so they cut this feature.

In fact they have cut many features from C and C++

If you declare a variable as public and even a class as public you will probably get a Global Variable. But such Practice is not advisable.

OR

declare your fields as Static and public. Even they will serve the purpose of Global Variables.

Hope it helps...

Answer Question

Anonymous