Substring Method

后端 未结 2 1910
忘掉有多难
忘掉有多难 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)

提交回复
热议问题