静态方法中访问类的实例成员

在静态方法中,先生成一个对象,用对象.成员访问实例成员

 static class Employee
 {
  String name;
  long salary;
  short employee_id;
  static int total_employees;
  static void clear(){
   Employee Empl =new Employee();
   Empl.name="hanhan";
   Empl.salary=20;
   total_employees=0;
  }
 }

原文地址:https://www.cnblogs.com/shouhutian/p/5983906.html