欢迎访问悦橙教程(wld5.com),关注java教程。悦橙教程  java问答|  每日更新
页面导航 : > > > 文章正文

substring(x)和substring(x,y)的用法,substring用法

来源: javaer 分享于  点击 18776 次 点评:104

substring(x)和substring(x,y)的用法,substring用法


代码:

public class textmu {
 /**
  * @param args
  */
 public static void main(String[] args) {
  // TODO Auto-generated method stub
    String id="123454321";
    String shortId,longId,Id;
    shortId=id.substring(2,7);
    longId=id.substring(1,8);
    Id=id.substring(4);
    System.out.println(shortId);
    System.out.println(longId);
    System.out.println(Id);
 }
}


总结:substring(x)是从字符串的的第x个字符截取
          substring(x,y)是从x到y前的位置停止
答案:


---------------------
作者:yhs17865569668
来源:CSDN
原文:https://blog.csdn.net/yhs17865569668/article/details/78189525
版权声明:本文为博主原创文章,转载请附上博文链接!

相关文章

    暂无相关文章

用户点评