-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJava Substring
More file actions
39 lines (29 loc) · 946 Bytes
/
Java Substring
File metadata and controls
39 lines (29 loc) · 946 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
34
35
36
37
38
39
/*
Given a string, , and two indices, and , print a substring consisting of all characters in the inclusive range from to . You'll find the String class' substring method helpful in completing this challenge.
Input Format
The first line contains a single string denoting .
The second line contains two space-separated integers denoting the respective values of and .
Constraints
String consists of English alphabetic letters (i.e., ) only.
Output Format
Print the substring in the inclusive range from to .
Sample Input
Helloworld
3 7
Sample Output
lowo
*/
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) {
Scanner in = new Scanner(System.in);
String S = in.next();
int start = in.nextInt();
int end = in.nextInt();
System.out.println(S.substring(start,end));
}
}