Possible Loss of Precision?
Hey so I'm doing an assignment relating to that Comparable and compareTo() methods. I'll just give you the prompt I got, my solution and what the error I received was:
Implement a new compareTo method for that class. Enter the appropriate code in the space provided below, so that employee A is considered less than employee B if the salary of employee A is less than the salary of employee B. Also, if the salary of employee A is equal to that of employee B, then they should be equal.
The error message I got was for the line and it said:
public int compareTo(Object obj)
//the header was given by the professor, everything below is mine
double b = ((Employee)obj).getSalary();
double a = this.salary;
"possible loss of precision
found : double
The methods return type seems to be defined as an Int from the header but if it is a salary it should be a double. If knowing the employee class is relevant, let me know and I'll edit.