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