[ Web Proxy ]
URL:
Viewing: https://programiz.com/java-programming/library/string/subsequence [Back]  [Original]

Java String subSequence()
Search tutorials & examples:

Java String subSequence()

The syntax of the subSequence() method is:

string.subSequence(int startIndex, int endIndex)

Here, string is an object of the String class.


subSequence() Parameters

The subSequence() method takes two parameters.

  • startIndex - the starting index (inclusive)
  • endIndex - the ending index (exclusive)

subSequence() Return Value

  • The subSequence() method returns a CharSequence.

Example: Java String subSequence()

class Main {
  public static void main(String[] args) {
    String str = "Java Programming";

    System.out.println(str.subSequence(3, 8)); // a Pro
  }
}
Did you find this article helpful?
phone:
submitted[dislike_feedback]:

Web Proxy Viewer  |  New URL  |  Original Page