title: how does this java code counts the number of things?
body: <p>Dumb question but can someone explain to me why the code below counts the number of thing objects? i do not understand why the count method defined counts the number of objects? when does the iteration begin? any help with the clarification will be really appreciated</p>
  <pre><code>class Thing {
  public String name;
  
      public static int count = 0;
      public Thing() {
  
          id = count;
          count++;
      }
      public void showName() {
          System.out.println(&quot;Object ID: &quot; + id + &quot;, &quot; + description + &quot;: &quot; + name);
      }
  }
  
  public class Java_Static {
  public static void main(String[] args) {
  
      
      // using count method
      System.out.println(&quot;Before creating objects, count is: &quot; + Thing.count);
  
      // using variable
      Thing thing1 = new Thing();
      Thing thing2 = new Thing();
  
      thing1.name = &quot;Abid&quot;;
      thing2.name = &quot;Ruksaar&quot;;
  
      thing1.showName();
      thing2.showName();
  
      System.out.println(&quot;After creating objects, count is: &quot; + Thing.count);
  
      
  
  
      
  
  }
  </code></pre>
  <p>}</p>