目录

boolean regionMatches(int toffset, String other, int ooffset, int len)

描述 (Description)

此方法有两个变体,可用于测试两个字符串区域是否相等。

语法 (Syntax)

以下是此方法的语法 -

public boolean regionMatches(int toffset,
                             String other,
                             int ooffset,
                             int len)

参数 (Parameters)

这是参数的细节 -

  • toffset - 此字符串toffset区域的起始偏移量。

  • other - 字符串参数。

  • ooffset - 字符串参数ooffset区域的起始偏移量。

  • len - 要比较的字符数。

返回值 (Return Value)

  • 如果此字符串的指定子区域与字符串参数的指定子区域匹配,则返回true;否则返回true。 否则是假的。 匹配是精确匹配还是不区分大小写取决于ignoreCase参数。

例子 (Example)

import java.io.*;
public class Test {
   public static void main(String args[]) {
      String Str1 = new String("Welcome to iowiki.com");
      String Str2 = new String("Tutorials");
      String Str3 = new String("TUTORIALS");
      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));
   }
}

这将产生以下结果 -

输出 (Output)

Return Value :true
Return Value :false
↑回到顶部↑
WIKI教程 @2018