-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJavaSubString.java
More file actions
33 lines (23 loc) · 773 Bytes
/
Copy pathJavaSubString.java
File metadata and controls
33 lines (23 loc) · 773 Bytes
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
// Q.Extract substring from start index to end index (end not included)
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void main(String[] args) {
// Create Scanner object to take input from user
Scanner in = new Scanner(System.in);
// Read the input string
String S = in.next();
// Read the starting index of substring
int start = in.nextInt();
// Read the ending index of substring
int end = in.nextInt();
// Close the Scanner
in.close();
S = S.substring(start, end);//for extracting substring.
// Print the extracted substring
System.out.println(S);
}
}