What is the range of variables declared in static blocks in Java?
•
Java
Can variables declared within static blocks be accessed elsewhere?
Solution
Usually, programmers do not need to declare any variables in static blocks. Usually, this is just to ensure the initialization of static variables for all class instances (depending on the range of static variables)
Variables declared in a static block will be local to the block like method and constructor variables
JDK Docs
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码