方法接口:
public string substring(int beginIndex,int endIndex)
用于截取字符串
第一个参数指明字符串截取起始位置
第二个参数指明字符串截取终止位置,
最终截取的字符串不包含endIndex位置的字符
eg:
"abcdefgh".substring(3,6);
//会截取到"def"
注意:
当传参数为一个时,表明从传参数位置一直截取到字符串末尾
eg:
"abcdefgh".substring(3);
//会截取到"defgh"
————————————————
eg:
截取倒数第一个字符之前的字符串,即不截取最后一个字符
String str = “1234567890”;
str.substring(0,str.length()-1);
////会截取到"123456789"