substring(int,int)就是取子串.第一个参数是子串的起始位置,从0开始,第二个参数是子串的长度.所以ss.substring(0,5)的结果是从0开始,长度为5的子串,即12345.其他的类似.

解决方案 »

  1.   

    substring这样定义
    0 1 2 3 4 5 6 7 
     1 2 3 4 5 6 7
    就是说你的1-7从0到7这样分配,这样应该很好解释了把
      

  2.   

    对的啊,有什么问题
    substring(int beginIndex, int endIndex)
      

  3.   

    String substring(int beginIndex, int endIndex) 
           Returns a new string that is a substring of this string. 
    两个参数beginindex和endindex表示要取的子串的下标范围,包括beginindex,不包括endindex。
      

  4.   

    ss = "1234567";
    System.out.println(ss.substring(2,3));
    //这个输出是 3System.out.println(ss.substring(3,3));
    //这个输出是空,难道不奇怪吗
    beginIndex 从0开始计数,endIndex 为什么从1开始计数?
      

  5.   

    System.out.println(ss.substring(3,3));
    //这个输出是空,难道不奇怪吗
    beginIndex 从0开始计数,endIndex 为什么从1开始计数?
    --------------------------------------------------------------------
                                  有什么奇怪,你取beginIndex是3,但endIndex 也是3,正因为endIndex是取前一个所以不能取3.这很合理呀
      

  6.   

    要学会查询api手册呀,朋友。