Substring Method

后端 未结 2 1875
忘掉有多难
忘掉有多难 2021-01-25 00:53

I had to write this program to output the first letter of a first name and the first five letters of the last name plus a random number from 10-99. It works but I thought that t

相关标签:
2条回答
  • 2021-01-25 01:10

    Java's substring inputs,

    public String substring(int beginIndex,int endIndex)
    
    beginIndex - the beginning index, inclusive.
    endIndex - the ending index, exclusive.
    

    Note the exclusive. substring(0,1) will return a string including character 0, up to but NOT including character 1.

    Source: http://docs.oracle.com/javase/7/docs/api/java/lang/String.html#substring(int, int)

    0 讨论(0)
  • 2021-01-25 01:30

    I hope you can better understand with this example:

    enter image description here

    0 讨论(0)
提交回复
热议问题