Given a string,S , and two indices, START and END,
print a substring consisting of all characters in the inclusive range from START to END-1.
You'll find the String class substring method helpful in completing this challenge.
Sample Input
Helloworld
3 7
Sample Output
lowo
Java Code:
import java.util.*;
public class javaSubstring {
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));
}
}
No comments:
Post a Comment