关于Main()的疑问
萝卜元三水 2016-02-28 12:17:09 package second;
import java.util.*;
public class neirong {
public static void main(String[] args) {
Employe[]staff=new Employe[3];
staff[0]=new Employe("Tom",4000);
staff[1]=new Employe("Dick",6000);
staff[2]=new Employe("Harry",6500);
//打印出工资以及姓名
for(Employe e:staff){
e.setId();
System.out.println("name="+e.getName()+",id="+e.getId()+",salary="+e.getSalary());
}
int n=Employe.getNextId();
System.out.println("Next available id="+n);
}
}
//Employe类的说明
class Employe{
private static int nextId = 1;
private String name;
private double salary;
private int id;
public Employe(String n, double s){
name=n;
salary=s;
id=0;
}
public String getName(){
return name;
}
public double getSalary(){
return salary;
}
public int getId(){
return id;
}
public void setId(){
id=nextId;
nextId++;
}
public static int getNextId(){
return nextId;
}
public static void main(String[]args){
Employe e=new Employe("Harry",5000);
System.out.println(e.getName()+" "+e.getSalary());
}
}
程序为什么不能执行neirong中的mian()函数,而且为什么Employe中的main()函数不能删去