14 May String regionMatches(boolean ignoreCase, int toffset, String other, int ooffset, int len) method in Java
The boolean regionMatches(boolean ignoreCase, int toffset, String other, int ooffset, int len) method in Java tests if two string regions are equal, with an option to ignore case or not.
Syntax
Let us see the syntax,
1 2 3 |
boolean regionMatches(boolean ignoreCase, int toffset, String other, int ooffset, int len) |
Parameters
Let us see the parameters,
- ignoreCase− if true, ignore case when comparing characters.
- toffset− starting offset of the subregion in this string.
- other− string argument
- ooffset− starting offset of the subregion in the string argument
- len− number of characters to compare
Example
The following is an example of regionMatches(boolean ignoreCase, int toffset, String other, int ooffset, int len),
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
public class StudyopediaDemo { public static void main(String args[]) { String message1 = new String("Studyopedia provides free learning content!"); System.out.println("String: "+message1); String message2 = new String("learning"); System.out.println(message1.regionMatches(true, 15, message2, 0, 7)); System.out.println(message1.regionMatches(true, 26, message2, 0, 8)); } } |
Output
The following is the output,
No Comments