我是 java 新手,我不断收到此错误消息:
无法访问 Managesalary 类型的封闭实例。必须使用 Managesalary 类型的封闭实例来限定分配(例如 xnew A(),其中 x 是 Managesalary 的实例)。在线的 *
public class Managesalary
{
public static void main(String[] args)
{
System.out.println("MY SALARY REVIEW");
System.out.println("================");
* Salary Jan= new Salary();
Jan.Month= "JANUARY";
Jan.HoursWorked= 12;
Jan.PerHourRate= 10;
Jan.TaxRate= 0.10;
Jan.printSalaryDetails();
Salary Month2= new Salary();
Month2.Month= "FEBUARY";
Month2.PerHourRate= 10;
Month2.TaxRate= 0.10;
Month2.printSalaryDetails();
}
class Salary
{
String Month = "";
int HoursWorked= 0;
int PerHourRate= 0;
double TaxRate= 0.10;
int MonthlySalary= (HoursWorked*PerHourRate);
public void printSalaryDetails(){
System.out.println("MONTH OF = " +Month);
System.out.println("PER HOUR RATE = " +PerHourRate);
System.out.println("TAX RATE = " +TaxRate);
System.out.println("TOTAL MONTHLY INCOME = " +MonthlySalary);
System.out.println("================");
}
}
}