Java static

What is "static" that precedes a java variable? I thought. .. ..

To explain in words, "variables associated with the original class field".

public class car{
   static int num_car = 0;
   String type;
   String color;

   Car(String type,String color){
      this.type = type;
      this.color = color;
      num_car++;
   }
}

When there is code like this, "type" and "color" are unique to the instance field, but since "num_car" is the number of instances, it is linked to the car class field itself and updated steadily. Things to go.

Recommended Posts

Java static
Java static story
static
Java static [Personal summary]
Java
Java
[Java] Stack area and static area
[Java] JavaConfig with Static InnerClass
[java] Reasons to use static
[Java] Classes, constructors, static members
Benefits of Java static method
Java learning (0)
Studying Java ―― 3
[Java] array
Java protected
[Java] Annotation
About Java static and non-static methods
[Java] Module
Java array
Studying Java ―― 9
Java scratch scratch
Java tips, tips
Java methods
Java method
java (constructor)
Java array
[Java] ArrayDeque
java (override)
java (method)
Java string
java (array)
Java serialization
java beginner 4
JAVA paid
Studying Java ―― 4
Java (set)
java shellsort
[Java] compareTo
Studying Java -5
java reflexes
java (interface)
Java memorandum
☾ Java / Collection
Java array
Studying Java ―― 1
[Java] Array
[Java] Polymorphism
Studying Java # 0
Java review
java framework
Java features
[Java] Inheritance
FastScanner Java
Java features
java beginner 3
Java memo
java (encapsulation)
Java inheritance
[Java] Overload
Java basics
Decompile Java