java 错在哪了

来源:百度知道 编辑:UC知道 时间:2024/05/21 23:37:57
package char01;

public class test {
public static void main(String[] arge){
em[] staff=new em[4];
staff[0]=new em("张三",2007010,4000);
staff[1]=new em("李四",2007011,6000);
staff[2]=new em("王五",2007012,6500);
staff[3]=new em("李六",2007013,7000);

for(int i=0;i<staff.length;i++)
{
em e=staff[i];
e.setId();
System.out.println("姓名="+e.getName()+",编号="+e.getId()+",学号="+e.getsas()+",工资"+e.getsalary());
}
int n=em.getNextId();
System.out.println("下一个有效编号="+n);
}
}
class em{
private String name;
private int sas;
private double salary;
private int id;
private static int naxId=1000;
public em(String name,double s,int a){
this.name=name;
sas=a;

public em(String name,double s,int a){
你的构造方法里边第二个参数不是工资吗?
可是呢new em的时候第二个参数给的都是2007010.0
这个东西,当然就串了...

恩。第二个参数double的工资。
em e=new em("张三",2007010,5000);这个好像传的是编号吧?

staff[0]=new em("张三",4000,2007010);
staff[1]=new em("李四",6000,2007011);
staff[2]=new em("王五",6500,2007012);
staff[3]=new em("李六",7000,2007013);