扫码一下
查看教程更方便
regionMatches() 方法有两种形式,可用于测试两个字符串部分是否相等。
public boolean regionMatches(int toffset,
String other,
int ooffset,
int len)
如果此字符串的指定子区域与字符串参数的指定子区域匹配,则返回 true; 否则为假。 区分大小写
public class Main {
public static void main(String args[]) {
String Str1 = new String("Welcome to jiyik.com");
String Str2 = new String("jiyik");
String Str3 = new String("JIYIK");
System.out.print("Return Value :" );
System.out.println(Str1.regionMatches(11, Str2, 0, 9));
System.out.print("Return Value :" );
System.out.println(Str1.regionMatches(11, Str3, 0, 9));
}
}
上面示例编译运行结果如下
Return Value :true
Return Value :false