Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

9
  • I was going to use int comparison =uno.compareTo(dos); and return comparison,but my employee class does not have a compareTo method and I do not think I can add it. Commented Jun 14, 2013 at 20:17
  • @user1166061 That is a perfectly viable option. It will require you to write a compareTo() function in your Employee class. You will need to think about how you want to 'order' your employees (i.e. by ID number or by payrate). Also think about what happens when the ID number is the same. Commented Jun 14, 2013 at 20:20
  • @user1166061 If you are not allowed to make a compareTo() function in Employee, then you can do the comparison in the compare function in your first set of code. Just use your get functions defined in Employee to determine how to order the Employees Commented Jun 14, 2013 at 20:23
  • @AlexBrooks that means the Employee class must have to implement Comparable<Employee> interface, which is not the purpose of the exercise, thus not a viable option for this problem. Commented Jun 14, 2013 at 20:23
  • 2
    @user1166061 It's the same thing for strings as presented for integers. The String object has a compare() and compareTo() that works in the same way. The result regards lexicographical order of the string. But as Luiggi pointed out, it seems your focus should be on the salary and how your teacher wants you to manipulate it to rank the Employees. Commented Jun 14, 2013 at 20:37