基本上我收到错误消息:“错误:无法找到或加载主类驱动程序”为什么我会收到此错误?这是我第一个使用类的实例,所以我不确定我的代码中的语法。任何帮助表示赞赏,谢谢。
public class Person {
private String name;//a variable that contains a person's name
private int age;//a variable that contain's a person's age
public class Driver{
public void main(String[] args )
{
String name1="John";
int age1=30;
Person person1= new Person();
person1.setName(name1);
person1.setAge(age1);
System.out.print(person1.getName());
System.out.print(person1.getAge());
}
}
//returns the age of a person
public int getAge(){
return age;
}
//returns the name of a person
public String getName()
{
return name;
}
//changes name of a person
public void setName(String s)
{
name=s;
}
//changes age of a person
public void setAge(int x)
{
age=x;
}
}