import java.util.Scanner;
/*
The cause is nextInt
If you enter 123 in nextInt
123 on the Java side\Converted to n (at the end\n is entered. )
nextInt returns only 123
Next, when you enter nextLine, it remains\n is read
An error occurs.
The solution is
Write nextLine without assignment to a variable. (Scanner from the following sources.nextLine())
By doing this\n is erased and nextLine works fine
* NextInt\Since there is no function to erase n, it is necessary to insert nextLine.
* Backslash and n represent line breaks.
*/
public class Hello {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int a = 0;
int b = 0;
String str = "";
a = scanner.nextInt();
b = scanner.nextInt();
scanner.nextLine();
str = scanner.nextLine();
System.out.println(str.substring(a - 1, b));
}
}
Recommended Posts