[Java] Characteristics of static variables

1 minute read

What is # Static?

In English, static This means that the type of method corresponds to the type of “static method”.

Variables that can be used without instantiating the class are called static variables.


Can be used with or without an instance. On the contrary, it cannot be used unless there is an instance other than static.

How to use #static variables

First, declare as follows.

Access modifier (such as public) static type name variable name

In the variable, the initial value is given when the data type is specified and declared.

Table of initial values

Integer: 0
float: 0.0f
double type: 0.0d
Character type:'\u0000'
boolean type: false
Reference type (String): null

How to call


Call using the class name instead of instantiating the class.

Changing with #static variables

You can access specified methods and member variables without new.


 public static String name = "";

    // static method
    public static String add(String ,int b){
        return a + b;

The above is usually called after instantiating (new), but by adding “static”, it can be used without “new”.


  • A static variable is a type of static variable and can be used without being instantiated.

  • On the contrary, other than that, it cannot be used unless instantiated.