复合的类.解决问题当场结帐,为什么我这个程序运行的时候有异常?

sylmoon 2004-04-14 08:44:28
/*java.lang.NoSuchMethodError: main
Exception in thread "main"
Process completed.*/

//why so many Exception

public class MyFather
{
public static void mian(String[] args)throws Exception
{
Person me=new Person(new Name("moon","su"),'M');
Person fa=new Person(new Name("yekui","su"),'M');
Person gp=new Person(new Name("zhenhuai","su"), 'M');
me.setFather(fa);
fa.setFather(gp);
System.out.println(me);
System.out.println(fa);
System.out.println(gp);
}
}
class Person
{
Person(Name name, char sex)
{
this.name=name;
this.sex=sex;
}

Name name()
{
return name;
}
void setFather(Person father )
{
this.father=father;
}
public String toSting()
{

return new String(""+father+"'s father"+this.father);

}


protected Name name;
protected char sex;
//protected String id;
//protected Person mother;
protected Person father;

}
class Name
{
Name(String first, String last)
{
this.first=first;
this.last=last;
}

String first()
{
return first;
}
String last()
{
return last;
}
private String first;
private String last;
}
...全文
86 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
tiger_wkh52741 2004-04-14
  • 打赏
  • 举报
回复
是你 手误吧!!
main()函数写错了!!
还有,抛出的异常最好要有catch相对应!
caiyanying732 2004-04-14
  • 打赏
  • 举报
回复
楼上都发现了
oxv 2004-04-14
  • 打赏
  • 举报
回复
你本来就是写错了嘛,看看你自己写的是不是main,你写成mian了
casemy 2004-04-14
  • 打赏
  • 举报
回复
没有main方法
不能运行

62,623

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧