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

后端 未结 8 1015
爱一瞬间的悲伤
爱一瞬间的悲伤 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:19

    Substrings are consecutive subsequences.

    For example, for sequence abc we have

    substrings: a, ab, abc, b, bc, c, and the empty substring;
    subsequences: a, b, ab, c, ac, bc, abc, and the empty subsequence.
    

    When the letters are repeated, some substrings and subsequences will look the same.

提交回复
热议问题