欢迎来到码农权的博客 MaNongGeGe|

字符串的截取方法

复制代码
 1 /*
 2     字符串的截取方法:
 3     public String substring(int index):截取从参数位置一直到字符串末尾,返回新字符串。
 4     public String substring(int begin,int end):截取从begin开始,一直到end结束,中间的字符串。
 5     备注[begin,end),包含左边,不包含右边。
 6 */
 7 public class Demo02 {
 8     public static void main(String[] args){
 9         String str1 = "HelloWorld";
10         String str2 = str1.substring(5);//方法一
11         String str3 = str1.substring(5,10);//方法二
12 
13         System.out.println("方法一:"+str2);//方法一:World
14         System.out.println("方法二:"+str3);//方法二:World
15     }
16 }
复制代码

 

本文作者:HuangBingQuan

本文链接:https://www.cnblogs.com/bingquan1/p/12506161.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   HuangBingQuan  阅读(284)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示
评论
收藏
关注
推荐
深色
回顶
收起
  1. 1 不将就 码农权
  2. 2 Bleeding Love 码农权
  3. 3 想你念你 码农权
Bleeding Love - 码农权
00:00 / 00:00
An audio error has occurred, player will skip forward in 2 seconds.

Not available