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

What is a static variable in java

王林
Release: 2020-05-14 14:01:52
Original
4705 people have browsed it

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!

Related labels:
Statement of this Website
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
Latest Issues
Install JAVA
From 1970-01-01 08:00:00
0
0
0
Unable to install java
From 1970-01-01 08:00:00
0
0
0
Can java be used as the backend of the web?
From 1970-01-01 08:00:00
0
0
0
Is this in Java language?
From 1970-01-01 08:00:00
0
0
0
Help: JAVA encrypted data PHP decryption
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template