Java String Regionmatches
# Java regionMatches() Method
[Java String Class](#)
* * *
The regionMatches() method is used to check if two strings are equal within a specific region.
### Syntax
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
* **ignoreCase** -- If true, the comparison ignores case.
* **toffset** -- The starting offset of the subregion in this string.
* **other** -- The string argument.
* **ooffset** -- The starting offset of the subregion in the string argument.
* **len** -- The number of characters to compare.
### Return Value
Returns true if the specified subregion of this string matches the specified subregion of the string argument; otherwise, returns false. Whether it's an exact match or case-insensitive depends on the ignoreCase parameter.
### Example
## Example
public class Test {
public static void main(String args[]){
String Str1 =new String("www.");
String Str2 =new String("");
String Str3 =new String("");
System.out.print("Return Value :");
System.out.println(Str1.regionMatches(4, Str2, 0, 5));
System.out.print("Return Value :");
System.out.println(Str1.regionMatches(4, Str3, 0, 5));
System.out.print("Return Value :");
System.out.println(Str1.regionMatches(true, 4, Str3, 0, 5));
}
}
}
The output of the above program is:
Return Value :true
Return Value :false
Return Value :true
* * Java String Class](#)
YouTip