title: Generate java class and call its method dynamically
body: <pre><code>package reflection;
  
  import java.io.*;
  
  import java.lang.reflect.*;
  
  class class0
  {
    public void writeout0()
    {
      System.out.println("class0");
    }
  }
  
  class class1
  {
    public void writeout1()
    { 
      System.out.println("class1");
    }
  }
  
  class class2
  {
    public void writeout2()
    {
      System.out.println("class2");
    }
  }
  
   class class3
  
  {
  
    public void run()
  
    {
  
      try
  
      {    
  
          BufferedReader reader= new BufferedReader(new InputStreamReader
  
  (System.in)); 
  
            String line=reader.readLine(); 
  
            Class cls=Class.forName(line);
                   //define method here
  
  
  
      }
  
      catch(Exception ee)
  
      {
  
     System.out.println("here "+ee);
  
      }
  
  
    }
    public void writeout3()
    {
        System.out.println("class3");
    }
  }
  
  class class4
  {
    public void writeout4()
    {
      System.out.println("class4");
    }
  }
  
  class class5
  {
    public void writeout5()
    {
      System.out.println("class5");
    }
  }
  
  class class6
  {
    public void writeout6()
    {
      System.out.println("class6");
    }
  }
  
  class class7
  {
    public void writeout7()
    {
      System.out.println("class7");
    }
  }
  
  class class8
  {
    public void writeout8()
    {
      System.out.println("class8");
    }
  }
  
  class class9
  {
    public void writeout9()
    {
      System.out.println("class9");
    }
  }
  
  
  
  class testclass {
  
      public static void main(String[] args) {
  
         System.out.println("Write class name : ");
  
          class3 example=new class3();
  
          example.run();
      }
  
  }
  </code></pre>
  
  <p>Question is ;
  third class will read the name of the class as String from console. Upon reading the name of the class, it will automatically and dynamically generate that class and call its writeout method.If that class is not read from input, it will not be initialized.</p>
  
  <p>but I can't continue any more ; I need to more something for 3.class, what can I do?</p>