Class variable in Java
<pre><code>class C3 {
    public static int n = 0;
    public int m = 0;

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

    public void display() {
        System.out.println(n + " " + m);}
    }
}
</code></pre>

<p>Execution of: - </p>

<pre><code>C3 c1 = new C3(); 
c1.display(); 
C3 c2 = new C3(); 
c1.display(); 
c2.display();   
</code></pre>

<p>Prints numbers (output)  </p>

<pre><code>1 1 
2 1 
2 1
</code></pre>

<p>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?</p>
