mar*_*cog 13
两者都是基于0的,但开始是包容性的,结束是独家的.这可确保生成的字符串具有长度start - end.
为了使substring操作更容易,可以想象字符在索引之间.
0 1 2 3 4 5 6 7 8 9 10 <- available indexes for substring
u n i v E R S i t y
? ?
start end --> range of "E R S"
Run Code Online (Sandbox Code Playgroud)
引用文档:
子字符串从指定的开始,
beginIndex并扩展到索引处的字符endIndex - 1.因此子串的长度是endIndex-beginIndex.