A class variable is also called a static variable, that is, a static variable is added before the variable;
Instance variables are also called object variables, that is, variables without static;
The difference is:
The difference between a class variable and an instance variable is that a class variable is shared by all objects. One object changes its value, and other objects get the changed result; instance variables are private objects. A certain object changes its value without affecting other objects;
Example:
Public Class {
Static int A = 0; // class variable
Private int B = 0; // Strength Variable
}
Public Class B {
Public void main (string [] ARGs) {
A a1 = new ();
A a2 = new A ();
a1.a = 3; // equivalent to. A = 3;
a1. B = 4;
system. out. println (a2.a); // The result is 3
// class variable is for all objects, so A1 changes a and A2's a also changes
system. out. println (a2. B); // The result is 0
// The instance only changes its own, so B of the A1 object changes, variable B of object A2 is not affected
}< BR >}