package changYongLei;
public class BiJiao_String {
public static void main(String[] args) {
// equalsIgnoreCase(String anotherString) 将此 String 与另一个 String 比较,不考虑大小写-----boolean
String s1 = "Hello world";
String s2 = "hello world";
String s3 = "healo world";
String s4 = "hello world";
System.out.println(s1.equalsIgnoreCase(s2));//true
System.out.println(s1.equalsIgnoreCase(s3));//false
// compareTo(String anotherString) 按字典顺序比较两个字符串,考虑大小写。-------int
// 如果两个字符串相等则返回0;如果字符串在该值之前则返回值小于0;如果字符串在该值之后则返回值大于0
// ASCII: A=65; a=97;
System.out.println(s1.compareTo(s2));//s1字符串的H在s2字符串h之前,返回负值
System.out.println(s2.compareTo(s3));//s2中l在s3中a后,返回正值
System.out.println(s2.compareTo(s4));
}
}