谁能告诉我这是什么意思?
我在看一段代码,由于看不懂想运行程序看书结果,
在编译下面程序时,出现这样的错误提示:
Employee should declared abstract it does not define compare (java.lang.object)是什么意思?
小弟还想多问一下,raiseSalary(double bypend )方法中的参数由那个变量传递给它。
import java.util.*;
import java.lang.*;
public class EmployeeTest {
public static void main(String[] args) {
Employee[] staff=new Employee[3];
staff[0]=new Employee("harry",7500);
staff[1]=new Employee("tony",700);
staff[2]=new Employee("tom",3600);
Arrays.sort(staff);
for(int i=0;i<staff.size();i++) {
Employee e=staff[i];
Systme.out.println("name="+e.getName()+",salary="+e.getSalary());
}
}
}
class Employee implenemts Compareble {
public Employee(String n,double s) {
name=n;
salary=s;
}
public String getName() {
return name;
}
public double getSalary() {
return salary;
}
public void raiseSalary(double bypend) {
double raise=salary*bypend/100;
salary+=raise;
}
public int compareTO(Object otherObject) {
Employee other=(Employee)otherObject;
if(salary>other.salary) return 1;
if(salary<other.salary) return -1;
return 0;
}
private String name;
private double salary;
}