regionMatches()
A.regionMatches(int x,String B,int y,int z);
从A字符串指定索引x与B字符串指定索引y开始比较,比较z个字符串。结果相同返回true,不同返回false。(直接看jdk源码会清楚一点)
举个例子:
String first_str = "https://www.baidu.com";
String second_str = "https://www.taobao.COM";
System.out.println(first_str.regionMatches(17, second_str, 18, 4));
System.out.println(first_str.regionMatches(true, 17, second_str, 18, 4));
结果为:
false
true