-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJava Substring
More file actions
34 lines (25 loc) · 839 Bytes
/
Copy pathJava Substring
File metadata and controls
34 lines (25 loc) · 839 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
/* Given a string, s, and two indices, start and end , 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 .
Sample Input
Helloworld
3 7
Sample Output
lowo
code
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();
String j=S.substring(start,end);
System.out.println(j);
}
}