Java字符串比较


public class comstring {
public static void main(String[] args) {
// TODO Auto-generated method stub

String a ="70099999";
String b = "RH007";
String s1 = "abc";
String s2 = "abcd";
String s3 = "abcdfg";
String s4 = "1bcdfg";
String s5 = "cdfg";
String s6 = "abc";
System.out.println(s1.compareTo(s2));//负值表示前小于后
System.out.println(s1.compareTo(s3));//0表示前后相等
System.out.println(s1.compareTo(s4));//前大于后
System.out.println(s1.compareTo(s5));//
System.out.println(s1.compareTo(s6));


// System.out.println(a>b);

}
}

posted on 2018-04-14 20:53  sunny_2016  阅读(87)  评论(0编辑  收藏  举报

导航