没有方法main?

viqkga123 viqkga123 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
public class Person
{
static int count =0;
protected String name;
protected int age;
public Person(String n1,int a1)
{
name=n1;
age=a1;
this.count++;
}
public String toString()
{
return this.name+","+this.age;
}
public void display()
{
System.out.print("本类名="+this.getClass().getName()+";");
System.out.println("父类名="+this.getClass().getSuperclass().getName());
System.out.print("Person.count="+this.count+" ");
System.out.print("Student.count="+Student.count+" ");
Object obj=this;
if(obj instanceof Student)
System.out.println(obj.toString()+"是Student类对象");
else if(obj instanceof Person)
System.out.println(obj.toString()+"是Person类对象");
}
}
class Student extends Person
{
static int count=0;
protected String dept;
protected Student (String n1,int a1,String d1)
{
super(n1,a1);
dept=d1;
this.count++;
}
public String toString()
{
return super.toString()+","+dept;
}
public void display()
{
super.display();
System.out.print("super.count="+super.count);
System.out.println(" ;this.count="+this.count);
}
public static void main(String args[])
{
Person per=new Person("王永涛",23);
per.display();
Student stu = new Student("张小三",22,"计算机系");
stu.display();
}
}
为什么会出现错误 exception in thread "main" java.lang.NoSuchMethodError:main
...全文

相关推荐

评论 12
收藏 已收藏
分享
返回顶部
viqkga123
Java SE 62,621 成员 307,251 内容