0

Why global variable concept not there in java ??

23rd Mar 2022, 1:04 AM
RAGHUNATHA REDDY CHAVVA
RAGHUNATHA REDDY CHAVVA - avatar
2 ответов
+ 2
CHAVVA RAGHUNATHA REDDY Technically not possible but You can declare at the start of the code.
23rd Mar 2022, 1:07 AM
A͢J
A͢J - avatar
0
In Java, the smallest separate structural unit is a class. The code begins to be written by writing a class where everything is encapsulated, which is an OOP requirement. In scripting languages, such as Python, where you can start writing code from 1 variable directly to the command line interpreter, global variables are needed because their future scope is unknown.
23rd Mar 2022, 8:20 AM
zemiak