public class Test8 {
public static void main(String[] args) {
String s1="abc";
String s2="abvs";
//比较结果有三种:负数,0,正数。负数代表前面的字符串小于后面的字符串,0表示两个字符串相等,正数代表前面的字符串大于后面的字符串
System.out.println(s1.compareTo(s2));
}
}
07-10
7833
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)