测试两个字符串区域是否相等。
boolean regionMatches - 语法
public boolean regionMatches(int toffset, String other, int ooffset, int len)
这是参数的详细信息-
toffset - 该字符串中子区域的起始偏移。
other - 字符串参数。
ooffset - 字符串参数中子区域的起始偏移。
len - 要比较的字符数。
boolean regionMatches - 返回值
如果此字符串的指定子区域与字符串参数的指定子区域匹配,则返回true;否则为fakse。匹配的精确性还是不区分大小写取决于ignoreCase参数。
boolean regionMatches - 示例
import java.io.*; public class Test { public static void main(String args[]) { String Str1=new String("Welcome to Learnfk.com"); String Str2=new String("Learnfk"); String Str3=new String("LEARNFK"); System.out.print("返回值 :" ); System.out.println(Str1.regionMatches(11, Str2, 0, 9)); System.out.print("返回值 :" ); System.out.println(Str1.regionMatches(11, Str3, 0, 9)); } }
这将产生以下输出-
返回值 :true 返回值 :false