Following example shows how to determines region matches in two String using regionMatches() method.
Sample Program
package com.javatutorialcorner.javastring;
public class RegionMatches {
public static void main(String[] args) {
String input1 = "Spring tutorials @ Java Tutorials Corner";
String input2 = "Learn Spring @ Java Tutorials Corner";
boolean isMatched = input1.
regionMatches(24, input2, 20, 16);
System.out.println();
System.out.println(isMatched);
}
}
Result
The above code checks region “Tutorials Corner” matches in both string .
true
0 comments:
Post a Comment