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;
}
}
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
Post a Comment