日期:2014-05-20 浏览次数:20869 次
import java.util.*;
public class Test
{
public static void main(String[] args)
{
String x = "10";
String y = "20";
System.out.println(x.compareTo(y));
System.out.println(compare(x, y));
}
}
import java.util.Comparator;
public class TestStr {
public static void main(String[] args) {
MyStringComparator comparator = new MyStringComparator();
System.out.println(comparator.compare("a", "b"));
}
}
class MyStringComparator implements Comparator<String>{
@Override
public int compare(String o1, String o2) {
return o1.compareTo(o2);
}
}
public class Test {
public static int compare(String x, String y) {
return x.compareTo(y);
}
public static void main(String[] args){
String x= "10";
String y = "20";
System.out.println(x.compareTo(y));
System.out.println(compare(x, y));
}
}