Topic: 类引用赋值问题,请教各位大虾!(NoSuchMethodError:main)

  Print this page

1.类引用赋值问题,请教各位大虾!(NoSuchMethodError:main) Copy to clipboard
Posted by: cyy
Posted on: 2005-12-28 20:50

源代码:
class Man{
int height;
int weigh;
int age;
}
public class Class2{
public static void main(){
Man man1=new Man();
Man man3;
man3=man1;
man1.height=180;
man1.weigh=60;
man1.age=36;
System.out.println("身高:"+man3.height+"cm");
System.out.println("体重:"+man3.weigh+"kg");
System.out.println("年龄:"+man3.age+"yo");
}
}

编译可以通过,但是运行时出现 Exception in thread "main" java.lang.NoSuchMethodError:main 的错误,说JAVA中没有这样的方式.不知道是什么原因?请各位前辈赐教!

2.Re:类引用赋值问题(NoSuchMethodError:main) [Re: cyy] Copy to clipboard
Posted by: why
Posted on: 2005-12-28 22:20

should be
public static void main(String[] args) {

3.Re:类引用赋值问题,请教各位大虾!(NoSuchMethodError:main) [Re: cyy] Copy to clipboard
Posted by: cyy
Posted on: 2005-12-28 23:13

谢谢!怎么这么粗心呢?Embaressed


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923