从另一个Java类调用内部类的方法

从另一个Java类调用内部类的方法,java,Java,我想将Salarycal()方法从Employee内部类employeeInfo调用到classExc public class Employee { public class employeeInfo{ int id; String name; int Salary; public employeeInfo(int id,String name,int Salary){

我想将
Salarycal()
方法从Employee内部类
employeeInfo
调用到class
Exc

public class Employee {

    public class employeeInfo{
            int id;
            String name;
            int Salary;


            public  employeeInfo(int id,String name,int Salary){
                this.id=id;
                this.name=name;
                this.Salary=Salary;

                System.out.println(id+name+Salary);
            }   
            public int Salarycal(){
                int totalSalary =0;
                int b=getId();
                           ........
            }
}
import Employer.Employee.employeeInfo;

public class Exc {


    public static void main(String[] args) {
         //want to access the salarycal() method in this class
        }

}

这就是我通常调用内部类的方法的方式

Inner inner = new Outer().new Inner();
inner.methodToInvoke();
就像@Ashish说的:

public static void main(String[] args) {
    new Employee().new employeeInfo().Salarycal();
}

PS.阅读

你需要一个
employeeInfo
的实例。。。你有吗?为什么你需要它成为一个内部类呢?(我建议在大多数情况下使用顶级类…)另外,只是一个风格建议:请不要为类使用小写名称。现在养成好习惯,以后与同事相处时少一些挫折感;)小写类和大写方法?这真的很难理解。在使用参数之前,还必须为参数实现setter和getter,例如:int b=getId();不打算使用。