Look at a python-written Java that actually writes out the global variables.
If you are familiar with PY oop, you can also know that there are no global variables in the class.
The variables in the class are divided into three kinds of attribute instance properties local variables, class attributes can also be called static property static variables, instance properties can also be similar to the meaning of member variables. But there is no global variable.
Why do some languages have global variables? JS py php all have.
In py, if you are using process-oriented programming, multiple functions manipulate a variable unless you frequently pass and return the arguments in multiple functions. Otherwise, you need to use global variables, because the function is at the module level of the namespace, then the function of the write variable outside the module can only be written below the module, the variable is called the global variable.
In the case of OOP programming, the namespace of the method is not under the module, but in the class name, so it is only necessary to write something that would have to be written as a global variable in a process-oriented way, as an instance or class attribute. This allows access to this variable in multiple methods. Because OOP sinks the namespace by one level, the module-class-method level three differs from the module-function level Two, which is oriented to the process.
Java is a language that enforces OOP, and all classes are namespaces, and of course there is no need for a global variable.
This is the same as I have previously confirmed, do not use global variables, especially global variable variables, and declare gloabl everywhere, really is the egg pain, a little bit of oop consciousness. Using OOP can completely eliminate global variables. been at ease for more than 10 years. Repeating a process-oriented low force code is not a good thing.
Why Java does not have global variables