Hi Jkid,

I have attached three files with the mail which will help explain you
the Comparator behaviour

Employee.java -- Bean for storing Employee data
Name.java      --  Name class used in sun tutorial
TestEmployee.java -- A test class explaining the comparator code.(Here
the comparison of Employee objects is done by using the date)

I have used only date , but you can use multiple criteria like number
.. try it yourself

Thanks,
Ashok A V


On Thu, Aug 6, 2009 at 9:51 PM, JKid314159<happy27...@yahoo.com> wrote:
> Re:
> The Java Tutorials:
> Home Page > Collections > Interfaces > Object Ordering:
> Comparators
>
> Dear Java Programmer:
> I got lost on this.  Can someone help me?  Please comment.  Thank you.
> this final Comparator Seniority is a variable?
>
> The ternary operator is doing???  There condition and then int or another
> condition to test which is also a ternary operator?
>
> static final Comparator<Employee> SENIORITY_ORDER =
>                                new Comparator<Employee>() {
>     public int compare(Employee e1, Employee e2) {
>         int dateCmp = e2.hireDate().compareTo(e1.hireDate());
>         if (dateCmp != 0)
>             return dateCmp;
>         return (e1.number() < e2.number() ? -1 :
>                 (e1.number() == e2.number() ? 0 : 1));
>     }
> };
>
>
> Respects,
>
> JKid314159
> http://existentialists.blogspot.com/
>
>
>
>
> >
>



-- 
Victory belongs to the most persevering.
 - Napoleon

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to javaprogrammingwithpassion@googlegroups.com
To unsubscribe from this group, send email to 
javaprogrammingwithpassion-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-~----------~----~----~----~------~----~------~--~---

Attachment: Employee.java
Description: Binary data

Attachment: Name.java
Description: Binary data

Attachment: TestEmployee.java
Description: Binary data

Reply via email to