我正在用 Java 编程,我遇到了以下异常......
"No enclosing instance of type Host is accessible. Must qualify the allocation with an enclosing instance of type Host (e.g. x.new A() where x is an instance of Host)."
这是相关的代码。任何人都告诉是什么导致了这个异常?
//Creating john
Employee john =new Employee(Name,Address,Age,Salary);
//closing the scanner
in.close();
john.info();
}
class Employee
{
//variables
private String name ="";
private String address="";
private double salary=0.0;
private int age=0;
//constructor
public Employee(String n, String add,int a, double s )
{
name = n;
address = add;
salary = s;
age = a;
}
public void info()
{
System.out.println(name);
System.out.println(address);
System.out.println(age);
System.out.println(salary);
}