I was using substring
in a project, earlier I was using endindex
position which was not creating the expected result, later I came to know that java substring
does endindex-1
. I found it not useful. So why Java is doing endindex-1
instead of plain endindex
?
My code is as follows.
String str = "0123456789";
String parameter1 = str.substring(0,4);
String parameter2 = str.substring(5,8);`