Why substring fun is not working ?....... | Sololearn: Learn to code for FREE!

0

Why substring fun is not working ?.......

https://code.sololearn.com/clomkl4j7Bg7/?ref=app

12/24/2019 11:14:43 AM

Muralikrishnan

3 Answers

New Answer

+3

As I understand it, substring takes 2 arguments: 1. The index of the first character. 2. The index of the last character The range of selection is <first index to last index - 1>. In your case, you should set it to `substring(3, 6)` and the method will return character from index 3, 4 and 5. Something along this line; str.substring(i, i + lenofsubstr));

+4

//substring(3,3) returns empty string so System.out.println(str.substring( i , i+lenofsubstr )); // substring from i, to i+3

+4

Line 13 should be: System.out.println(str.substring( i , i+lenofsubstr ));