HackerRank Java- Substring
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.
- 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 scan = new Scanner(System.in);
- String str = scan.next();
- int start = scan.nextInt();
- int end = scan.nextInt();
- scan.close();
-
- System.out.println(str.substring(start, end));
- }
- }