java - Static Error: This class does not have a static void main method accepting String[]. -
my code compiles fine when go run it, gives me error:
`static error: class not have static void main method accepting string[]` here code:
class employee{ private string name; //name reference field private int idnumber; //integer variable holding employee's id number private string department; //holds name of employees department private string position; //holds name of employee's position in department //the following first required constructor //using terms n,i,d, , p assign values above fields public employee(string n, int i, string d, string p){ name=n; idnumber=i; department=d; position=p; } //the following constructor sets fields blank filled in public employee(){ name=""; idnumber=0; department=""; position=""; } //writing appropriate accessor , mutator methods fields public void setname(string n){ name=n; } public void setidnumber(int i){ idnumber = i; } public void setdepartment(string d){ department = d; } public void setposition(string p){ position = p; } public string getname(){ return name; } public int getidnumber(){ return idnumber; } public string getdepartment(){ return department; } public string getposition(){ return position; } } //new program creating employee objects public class employeeinfo { public static void main(string[] args) { //create employee object employee employee1 = new employee("susan meyers", 47899, "accounting", "vice president"); //test accessor methods system.out.println("***employee1***"); system.out.println("name: " + employee1.getname()); system.out.println("id number: " + employee1.getidnumber()); system.out.println("department: " + employee1.getdepartment()); system.out.println("position: " + employee1.getposition()); //create employee object employee employee2 = new employee(); //test mutator methods employee2.setname("mark jones"); employee2.setidnumber(39119); employee2.setdepartment("it"); employee2.setposition("programmer"); system.out.println("\n***employee2***"); system.out.println("name: " + employee2.getname()); system.out.println("id number: " + employee2.getidnumber()); system.out.println("department: " + employee2.getdepartment()); system.out.println("position: " + employee2.getposition()); //create employee object employee employee3 = new employee(); //test mutator methods employee2.setname("joy rogers"); employee2.setidnumber(81774); employee2.setdepartment("manufacturing"); employee2.setposition("engineer"); system.out.println("\n***employee3***"); system.out.println("name: " + employee3.getname()); system.out.println("id number: " + employee3.getidnumber()); system.out.println("department: " + employee3.getdepartment()); system.out.println("position: " + employee3.getposition()); } } i know need add "public static void main(string[] args)" command somewhere i'm not sure where! thank can give!
you creating 2 different class employee , employeeinfo assuming trying execute employee class compiler unable find public static void main
Comments
Post a Comment