0

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

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

24th Dec 2019, 11:14 AM
Muralikrishnan
Muralikrishnan - avatar
3 Respostas
+ 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));
24th Dec 2019, 11:43 AM
Ipang
+ 4
//substring(3,3) returns empty string so System.out.println(str.substring( i , i+lenofsubstr )); // substring from i, to i+3
24th Dec 2019, 11:22 AM
zemiak
+ 4
Line 13 should be: System.out.println(str.substring( i , i+lenofsubstr ));
24th Dec 2019, 11:34 AM
Coding Cat
Coding Cat - avatar