First, since the endpoint is excluded, s.substring(i,j) has a length ji (which is intuitively correct).
For another, s.substring(i,j) + s.substring(j,k) is equal to s.substring(i,k) (for reasonable values ββof i , j and k ).
In addition, s.substring(0, s.length()) describes all s as it should, because the endpoint is excluded.
If the endpoint was turned on, you constantly had to remember to add or subtract it from things to make the work work.
Matcher.end() is consistent with them: start-inclusive, end-exclusive, so s.substring(m.start(), m.end()) gives a substring.
source share