Infolinks In Text Ads

Jun 25, 2010

How to implements Comparator interface in java code examples

import java.util.Comparator;

public class TagComparator implements Comparator{
   
    public int compare(Object arg0, Object arg1) {
        // TODO Auto-generated method stub
        int r = 0;
       
        if (arg0.toString().length() > arg1.toString().length())
            r = 1;
        else
            r=0;
       
        return r;
    }
}

No comments:

Post a Comment

LinkWithin

Related Posts Plugin for WordPress, Blogger...