title: Difference static behaviour between MyClass.class and Class.forName(“MyClass”)
body: <p>I'm not sure what's the difference of loading static variables/blocks between <code>MyClass.class</code> and <code>Class.forName("MyClass")</code>, for example, I have below class:</p>
  
  <pre><code>package test;
  public class SampleClass{
      public static SampleClass instance = new SampleClass();
      private SampleClass(){
         System.out.println("SampleClass Instance Created");
      }
  }
  </code></pre>
  
  <p>Then, in another class, I accessed the class object of above SampleClass by using:</p>
  
  <pre><code>System.out.println(SampleClass.class);
  </code></pre>
  
  <p>Then, the output will be:</p>
  
  <pre><code>class test.SampleClass
  </code></pre>
  
  <p>If I changed to use <code>class.forName()</code>, as below:</p>
  
  <pre><code> System.out.println(Class.forName("test.SampleClass"));
  </code></pre>
  
  <p>Then, the output will be:</p>
  
  <pre><code> SampleClass Instance Created
   class test.SampleClass
  </code></pre>
  
  <p>Does anybody can give me an explanation?
  Thanks a lot.</p>