有没有包名,例如:
Class.forName("java.lang.String")

解决方案 »

  1.   

    没问题了:
    package com;/**
     * Created by IntelliJ IDEA.
     * User: Administrator
     * Date: 2004-4-29
     * Time: 19:08:52
     * To change this template use File | Settings | File Templates.
     */
    import java.util.*;
    import java.lang.*;
    interface Shape{
    void draw();
    }
    class Circle implements Shape {
      public void draw()
      {
    System.out.println("Circle.draw() ");
      }
    }
    public class Shapes{
      public static void main(String[] args){
          try {
              Class c1 = Class.forName("com.Circle");   // 1
              ((Circle)c1.newInstance()).draw();     // 2
          } catch (ClassNotFoundException e) {
              e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
          } catch (InstantiationException e) {
              e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
          } catch (IllegalAccessException e) {
              e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
          }
      }
    }
      

  2.   

    为什么做一个包就可以了?
    默认的包 不是`default`么,为什么一定要写出一个com?`
    请教了
      

  3.   

    用命令行形式编译执行无问题! 不涉及包的问题,很可能是Eclipse的问题!
      

  4.   

    nenu0 (方枪枪) = tmouse(方枪枪) 自问自答