方法接口:
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"