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








Syntax

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

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

Example

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

//from w  w w.  j  a v a 2s.  c  o m

public class Main {

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

    
    str2 = "Consists of different Tutorials";
    boolean match1 = str1.regionMatches(true, 14, str2, 22, 10); 
    System.out.println("region matched = " + match1);   
  }
}

The code above generates the following result.