2 compareTo method overriden in the same class definition, how could I force to use the second?

Posted by jayjaypg22 on Stack Overflow See other posts from Stack Overflow or by jayjaypg22
Published on 2010-12-22T13:45:34Z Indexed on 2010/12/22 13:54 UTC
Read the original article Hit count: 181

Filed under:
|
|
|

I want to sort a list List<Blabla> donnees by a criterion on one of its field. My problem is that compareTo is already overriden for this Class. So I've got something like :

Blabla {

    public int compareTo(Object other) {
        ...
     }

    public int compareTo(Blabla other) {
        ... 
     }

}

In a business layer class I call :

Business {
   method (){
       Collections.sort(List<Blabla > donnees);
   }

}

But this call N°1 compareTo method with object parameter. How could I sort my list with the N°2 method?

© Stack Overflow or respective owner

Related posts about java

Related posts about list