-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringTask2.java
More file actions
37 lines (23 loc) · 1.02 KB
/
Copy pathStringTask2.java
File metadata and controls
37 lines (23 loc) · 1.02 KB
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
35
36
import java.util.Scanner;
import java.util.Scanner;
public class StringTask2 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter first string: ");
String firstString = scanner.nextLine();
System.out.print("Enter second string: ");
String secondString = scanner.nextLine();
System.out.print("Enter starting index: ");
int startingIndex = scanner.nextInt();
System.out.print("Enter number of characters to compare: ");
int numberOfCharacters = scanner.nextInt();
boolean regionsAreEqual = firstString.regionMatches(
true, startingIndex, secondString, startingIndex, numberOfCharacters
);
if (regionsAreEqual) {
System.out.println("The regions are equal (ignoring case).");
} else {
System.out.println("The regions are NOT equal.");
}
}
}