返回此字符串的子字符串,该子字符串从startIndex(包括在内)到endIndex(不包括)之间。
substring(int startIndex, [ int endIndex ])
startIndex - 开始从(包括)开始提取的索引。
endIndex - 停止提取的索引(专有)。
注意-索引从零开始,即第一个字符的索引为0,依此类推。
返回一个字符串。
void main() { String str1="Hello Learnfk"; print("New String: ${str1.substring(6)}"); //from index 6 to the last index print("New String: ${str1.substring(2,6)}"); //from index 2 to the 6th index }
它将产生以下输出-。
New String: Learnfk New String: llo
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)