Java Data Type Tutorial - Java String.regionMatches(int toffset, String other, int ooffset, int len)








Syntax

String.regionMatches(int toffset, String other, int ooffset, int len) has the following syntax.

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

Example

In the following code shows how to use String.regionMatches(int toffset, String other, int ooffset, int len) method.

//w  w  w.  j a  va2 s . co  m
public class Main {

  public static void main(String[] args) {
  
    String str1 = "tutorials from java2s.com";
    String str2 = "Java tutorials from java2s.com";


    boolean match1 = str1.regionMatches(14, str2, 22, 9);
    System.out.println("region matched = " + match1);

    System.out.println("region matched = " + match1);   
  }
}

The code above generates the following result.