Home  >  Article  >  Java  >  What is a static variable in java

What is a static variable in java

王林
王林Original
2020-05-14 14:01:524599browse

What is a static variable in java

What are static variables?

Static variables refer to variables modified by the static keyword, also called class variables.

There is only one static variable of the class in memory. The Java virtual machine allocates memory for static variables during the process of loading a class. The static variables are located in the method area and are shared by all instances of the class. Static variables can be accessed directly through the class name, and their life cycle depends on the life cycle of the class.

(Video tutorial recommendation: java video)

Let’s take a look at the order of initialization in JAVA:

Loading class;

Static variable initialization;

Static block; [It can only schedule static ones, not non-static ones]

Member variables;

Construction method;

Recommended tutorial: java entry program

The above is the detailed content of What is a static variable in java. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn