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;
    }
}

Comments

Recent Post

Recent Posts Widget

Popular posts from this blog

Capture image from webcam java code, examples

How to capture finger prints in java

Shallow Copy Deep Copy Java example