Java - String regionMatches() Method

Description:

This method has two variants which can be used to test if two string regions are equal.

Syntax:

Here is the syntax of this method:

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

or

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

Parameters:

Here is the detail of parameters:


Return Value :



Example:

import java.io.*;

public class Test{
   public static void main(String args[]){
      String Str1 = new String("Welcome to www.dineshonjava.com");
      String Str2 = new String("dineshon");
      String Str3 = new String("DINESHON");

      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));

      System.out.print("Return Value :" );
      System.out.println(Str1.regionMatches(true, 11, Str3, 0, 9));
   }
}

This produces following result:

output:
Return Value :false
Return Value :false
Return Value :false


<<Previous <<   || Index ||   >>Next >>



Labels: