Question:
why doesnt this java code work?
wolfshalabh
2010-09-21 19:02:30 UTC
import java.util.*;
public class Employee
{

public String FirstName;
public String LastName;
private float Salary;
private int JobGrade;

public Employee()
{
FirstName ="";
LastName ="";
Salary = 0.0f;
JobGrade = 0;
}

public Employee(String First, String Last)
{
FirstName = First;
LastName = Last;
Salary = 0.0f;
JobGrade = 0;
}

public Employee(String First, String Last, float salary, int grade)
{
FirstName = First;
LastName = Last;
Salary = salary;
JobGrade = grade;
}

public void SetSalary(float Dollars)
{
Salary = Dollars;
}

public float GetSalary()
{
return Salary;
}

public void SetJobGrade(int grade)
{
JobGrade = grade;
}

public void SetJobGrade(String Grade)
{
if (Grade.equals("CEO"))
{
JobGrade = 3;
}
else if (Grade.equals("MANAGER"))
{
JobGrade = 2;
}
else if (Grade.equals("DEVELOPER"))
{
JobGrade = 1;
}
}

public int GetJobGrade()
{
return JobGrade;
}

}


i keep getting this error
java.lang.NoSuchMethodError: main
Exception in thread "main"
----jGRASP wedge2: exit code for process is 1.
----jGRASP: operation complete.
Three answers:
?
2010-09-21 19:42:32 UTC
you dont have a main method.



add this to your Main class.



public static void main(String[]args){

// do something

}
2010-09-22 03:32:22 UTC
You can compile this code but to run it you should have main method in it so add main method
Xan
2010-09-22 02:41:47 UTC
Perhaps you can read this:



http://leepoint.net/notes-java/background/13files_and_directories/noSuchMethodError.html



Good luck.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...