Java String.subSequence()

The method subSequence() obtains a part of a String given the
starting index and the length of the result. The method SubSequence()
behaves in the same way as substring().

The only difference is that it returns a CharSequence instead of a

Available Signatures

public CharSequence subSequence(int beginIndex, int endIndex)


public void whenCallSubSequence_thenCorrect() {
    String s = "Welcome to Baeldung";

    assertEquals("Welcome", s.subSequence(0, 7));

Next »

« Previous

Leave a Reply

Your email address will not be published. Required fields are marked *