截取beginIndex索引开始到endIndex结束之间的字符串内容。
这是此方法的语法-
链接:https://www.learnfk.comhttps://www.learnfk.com/java/java-string-substring-beginendindex.html
来源:LearnFk无涯教程网
public String substring(int beginIndex, int endIndex)
这是参数的详细信息-
beginIndex - 包含开始索引。
endIndex - 不包含结束索引。
import java.io.*; public class Test { public static void main(String args[]) { String Str=new String("Welcome to Learnfk.com"); System.out.print("返回值 :" ); System.out.println(Str.substring(10, 15) ); } }
这将产生以下输出-
返回值 : Lear
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)