大家帮我看一下 下面这段 代码好吗?
怎么连接时 有 Exception in thread "main" java.lang.NoSuchMethodError:main
的错误呢? 我一直都找不到原因,各位大虾 帮我看一下 好吗? 谢谢!
public interface ConversionFators{
  double INCH_TO_MM = 25.4;
  double OUNCE_TO_GRAM = 28.349;
  double POUND_TO_GRAM = 453.59;
  double HP_TO_WATT = 745.7;
  double WATT_TO_HP = 1.0/HP_TO_WATT;
}
interface Shape{
void draw(); 
void print();
}
class Point{
int x,y;
Point(int x, int y){
this.x = x;
this.y = y;
}
void moveTo(int newx, int newy){
x = newx; y = newy;
}
public String toString(){
return(x+" "+y);
}
class Circle implements Shape{
Point center;
int radius;
Circle(){
this(0,0,0);
}
Circle(int x, int y, int size){
center = new Point(x,y);
radius = size;
}
public void draw(){
System.out.println("Drawing a Circle of radius"+radius+"at"+center);
}
public void print(){
System.out.println("Circle("+center+" "+radius+")");
}
public void main(String[] args){
Shape s[] = new Shape[3];
for(int i = 0; i < 3; i++)
{ s[i] = new Circle(i,i,i);}
for(int i = 0; i < 3; i++)
{ s[i].print();   }
}
}
}

解决方案 »

  1.   


    public static void main(String[] args){}
    可能是这个原因。
      

  2.   

    应该不是static 的原因,因为我将static 加上过后,会有
    the method main cannot be declared static, static method can only be declared in a static or top level type;
      

  3.   

    ...这个是因为没有提供main入口函数的原因吧
    你拿eclipse跑下,会发现它让你找"main"
      

  4.   

    恩 我用的就是eclipse, 结果 是让我找main
     但是 这个小程序结构 已经完了,怎么才 可以 有main的入口函数呢
      

  5.   

    楼上说的基本都正确,main方法一定要用static修示,他可是程序的入口啊,首先你一定要写成public static void main(String[] args){}
    这只是第一点,第二点就是,你的main方法在一个内部类中,你没看到吗?????
    class Point{ 
    int x,y; 
    Point(int x, int y){ 
    this.x = x; 
    this.y = y; 

    void moveTo(int newx, int newy){ 
    x = newx; y = newy; 

    public String toString(){ 
    return(x+" "+y); 

    }public class Circle implements Shape{ 
    Point center; 
    int radius; 
    Circle(){ 
    this(0,0,0); 

    Circle(int x, int y, int size){ 
    center = new Point(x,y); 
    radius = size; 

    public void draw(){ 
    System.out.println("Drawing a Circle of radius"+radius+"at"+center); 

    public void print(){ 
    System.out.println("Circle("+center+" "+radius+")"); 

    public static void main(String[] args){ 
    Shape s[] = new Shape[3]; 
    for(int i = 0; i  < 3; i++) 
    { s[i] = new Circle(i,i,i);} 
    for(int i = 0; i  < 3; i++) 
    { s[i].print();   } 

    } 这样就没问题了.你试试
      

  6.   

    其实调试的时候 看到了如果加上static ,main方法会在内部类里面。
    但是我  不知道怎么来修改这个问题 ,呵呵!
    谢谢你!