java.lang.StringBuffer codePointCount(int beginIndex,int endIndex)

Description :

This java tutorial shows how to use the codePointCount(int beginIndex,int endIndex) method of StringBuffer class under java.lang package.

The codePointCount(int beginIndex,int endIndex) returns the number of Unicode code points in the specified text range of this sequence. The text range begins at the specified beginIndex and extends to the char at index endIndex – 1. Thus the length (in chars) of the text range is endIndex-beginIndex. Unpaired surrogates within this sequence count as one code point each.

Method Syntax :

public int codePointCount(int beginIndex,int endIndex)

Parameter Input :

DataType Parameter Description
int beginIndex the index to the first char of the text range.
int endIndex the index after the last char of the text range.

Method Returns :

The codePointCount(int beginIndex,int endIndex) method simply returns the number of Unicode code points in the specified text range.

Compatibility Version :

Requires Java 1.5 and up

Java Code Example :

This java example source code demonstrates the use of codePointCount(int beginIndex,int endIndex) method of StringBuffer class. Initially the code assigns a string “javatutorialhq.com” as initial contents of the string buffer. Then we use the codePointCount(int beginIndex,int endIndex) of the StringBuffer starting at index 2 until index 5.

Sample Output :

Running the codePointCount(int beginIndex,int endIndex)  method example source code of StringBuffer class will give you the following output

Java StringBuffer codePointBefore(int index) method example

Java StringBuffer codePointBefore(int index) method example

Exception Scenario :

N/A

Similar Method :

  • N/A

Suggested Reading List :

References :