Bootstrap

java this关键字详解_java-this关键字详解

48304ba5e6f9fe08f3fa1abda7d326ab.png

package org.lyk.entities;

public class Emp implements Comparable

{

private long empno;

private String ename;

private String job;

private float sal;

public long getEmpno()

{

return empno;

}

public void setEmpno(long empno)

{

this.empno = empno;

}

public String getEname()

{

return ename;

}

public void setEname(String ename)

{

this.ename = ename;

}

public String getJob()

{

return job;

}

public void setJob(String job)

{

this.job = job;

}

public float getSal()

{

return sal;

}

public void setSal(float sal)

{

this.sal = sal;

}

@Override

public String toString()

{

return "Emp [empno=" + empno + ", ename=" + ename + ", job=" + job + ", sal=" + sal + "]";

}

public Emp()

{

this(-1, "无名氏", "未指定", 0);

}

public Emp(long empno)

{

this(empno,"无名氏","未指定",0);

}

public Emp(long empno, String name)

{

this(empno, name, "未指定", 0);

}

public Emp(long empno, String ename, String job, float sal)

{

super();

this.empno = empno;

this.ename = ename;

this.job = job;

this.sal = sal;

}

@Override

public int compareTo(Emp o)

{

if(this.sal < o.sal)

return -1;

else if(this.sal > o.sal)

return 1;

if(this.empno < o.empno)

return -1;

else if(this.empno > o.empno)

return 1;

return 0;

}

}

48304ba5e6f9fe08f3fa1abda7d326ab.png

;