- 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);
- }
- }
来源: http://www.bubuko.com/infodetail-2562516.html