RegionMatches
The regionMatches () method of String compares a specific region inside a string with another specific region in another string. There is an overloaded form that allows you to ignore case in such comparisons. It has two forms:
For both versions, ‘toffset’ specifies the index at which the region begins within the invoking String object. The String being compared is specified by ‘other’. The index at which the comparison will start within ‘other’ is specified by ‘ooffset’. The length of the substring being compared is passed in ‘len’. In the second version, if ignoreCase is true, the case of the characters is ignored. Otherwise, case is significant. For examples:
Program
Program Source
public class Javaapp { public static void main(String[] args) { String str = "ABCDEFGHIJ"; if (str.regionMatches(3, "XXDEFYY", 2, 3)) { System.out.println("Both regions are same"); }else{ System.out.println("Both regions are different"); } } }
Very descriptive post, I loved that bit. Will there
be a part 2?
Also visit my web site: House Water Filtration System
I’ll immediately grab your rss feed as I can not to find your
e-mail subscription link or e-newsletter service.
Do you have any? Kindly permit me know in order that I may subscribe.
Thanks.
Take a look at my page … Home water filtration options