Question: ```
class C3 {
    public static int n = 0;
    public int m = 0;

    public C3() {
        n++; 
        m++; 
    }

    public void display() {
        System.out.println(n + " " + m);}
    }
}

```

Execution of: - 

```
C3 c1 = new C3(); 
c1.display(); 
C3 c2 = new C3(); 
c1.display(); 
c2.display();   

```

Prints numbers (output) 

```
1 1 
2 1 
2 1

```

Can anyone please explain me the output step by step? i am a bit confused about the 2nd line of output, why didn't both m and n value increase? also in 3rd output why didn't it start from beginning?

Answer: 
**n** is a `static variable`, thus all instances(c1 and c2 in this case) of the class share its data, where as **m** isn't a `static variable`, that means, each instance gets its own value of **m**

```
 //initial vals n=0 m=0;
  C3 c1 = new C3(); 
 //value of n is 1 value of m is 1   
 c1.display();

//initial values n=0, m=1(as c1 just incremented n which is static and c2 will now inc      n's current value(which is 1))    
C3 c2 = new C3(); 
//value of n is 2 value of m is 1 
c1.display(); 
c2.display();  

```
Every object you instantiate will have `m = 1` because m is an instance variable.
`n`, on the other hand, is a class variable. Every object you instantiate will increase the n by 1.

In your case, `n` will count how many objects you have created.