测试两个字符串区域是否相等。
这是此方法的语法-
public boolean regionMatches(boolean ignoreCase, int toffset, String other, int ooffset, int len)
这是参数的详细信息-
toffset -该字符串中子区域的起始偏移。
other -字符串参数。
ooffset -字符串参数中子区域的起始偏移。
len -要比较的字符数。
ignoreCase -如果为true,则在比较字符时忽略大小写。
如果此字符串的指定子区域与字符串参数的指定子区域匹配,则返回true;否则为false。匹配的精确性还是不区分大小写取决于ignoreCase参数。
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"); System.out.print("返回值 :" ); System.out.println(Str1.regionMatches(true, 11, Str2, 0, 9)); } }
这将产生以下输出-
返回值 :true
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)