What is the difference between String.subString() and String.subSequence()

后端 未结 8 1013
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-25 11:34

String.subSequence() has the following javadoc:

Returns a new character sequence that is a subsequence of this sequence.

8条回答
  •  心在旅途
    2020-12-25 12:20

    Basically it is just what is returned. One a String and the other a CharSequence (which you can cast as a string).
    You would use the subSequence when you need a CharSequence type of variable.

提交回复
热议问题