-
Notifications
You must be signed in to change notification settings - Fork 34
/
string-op
34 lines (28 loc) · 889 Bytes
/
string-op
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Java Program to find if substrings or regions of two
// strings are equal
import java.io.*;
class CheckIfRegionsEqual {
public static void main(String args[])
{
// create three string objects
String str1 = new String(
"Welcome to Geeksforgeeks.com");
String str2 = new String("Geeksforgeeks");
String str3 = new String("GEEKSFORGEEKS");
// Comparing str1 and str2
System.out.print(
"Result of Comparing of String 1 and String 2: ");
System.out.println(
str1.regionMatches(11, str2, 0, 13));
// Comparing str1 and str3
System.out.print(
"Result of Comparing of String 1 and String 3: ");
System.out.println(
str1.regionMatches(11, str3, 0, 13));
// Comparing str2 and str3
System.out.print(
"Result of Comparing of String 2 and String 3: ");
System.out.println(
str2.regionMatches(0, str3, 0, 13));
}
}