Java substring() 方法
substring() 方法返回字符串的子字符串。
语法
public String substring(int beginIndex)
或
public String substring(int beginIndex, int endIndex)
参数
beginIndex — 起始索引(包括), 索引从 0 开始。
endIndex — 结束索引(不包括)。
返回值
- 子字符串。
public class Test {
public static void main(String args[]) {
String Str = new String("blog.csdn.net/Mrs_chens");
System.out.print("返回值 :" );
System.out.println(Str.substring(5) );
System.out.print("返回值 :" );
System.out.println(Str.substring(5, 9) );
}
}
以上程序执行结果为:
返回值 :csdn.net/Mrs_chens
返回值 :csdn
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/97648.html