title: Class.forName() throws ClassNotFoundException
body: <p>A Thinking in Java program is as follows:</p>
  
  <pre><code>package typeinfo;
  import static util.Print.*;
  
  class Candy {
   static { print("Loading Candy"); }
  }
  
  class Gum {
   static { print("Loading Gum"); }
  }
  
  class Cookie {
   static { print("Loading Cookie"); }
  }
  
  public class SweetShop {
   public static void main(String[] args) {  
     print("inside main");
     new Candy();
     print("After creating Candy");
     try {
       Class.forName("Gum");
     } catch(ClassNotFoundException e) {
       print("Couldn't find Gum");
     }
     print("After Class.forName(\"Gum\")");
     new Cookie();
     print("After creating Cookie");
   }
  } 
  </code></pre>
  
  <p>I am expecting the output as follows:</p>
  
  <pre><code>/* Output:
  inside main
  Loading Candy
  After creating Candy
  Loading Gum
  After Class.forName("Gum")
  Loading Cookie
  After creating Cookie
  */
  </code></pre>
  
  <p>But get</p>
  
  <pre><code>inside main
  Loading Candy
  After creating Candy
  Couldn't find Gum
  After Class.forName("Gum")
  Loading Cookie
  After creating Cookie
  </code></pre>
  
  <p>Obviously the try block is throwing a ClassNotFoundException, which is unexpected. Any ideas why the code throws this instead of initializing the Gum class, as expected?</p>