java.lang.StringBuffer offsetByCodePoints(int index,int codePointOffset)

Description :

This java tutorial shows how to use the offsetByCodePoints(int index,int codePointOffset) method of StringBuffer class under java.lang package.

The offsetByCodePoints(int index,int codePointOffset) returns the index within this sequence that is offset from the given index by codePointOffset code points.

Method Syntax :

public int offsetByCodePoints(int index,int codePointOffset)

Parameter Input :

DataType Parameter Description
int index index to be offset
int codePointOffset offset in code points

Method Returns :

This method simply returns the index within this sequence stored on the buffer.

Compatibility Version :

Requires Java 1.5 and up

Java Code Example :

This java example source code demonstrates the use of offsetByCodePoints(int index,int codePointOffset) method of StringBuffer class. Initially the code assigns a string “” as initial contents of the string buffer. Then we use offsetByCodePoints method with method argument of index as 2 and codepointoffset of 5.

Sample Output :

Running the above example source code will give the following output

Java StringBuffer offsetByCodePoints() method example

Java StringBuffer offsetByCodePoints() method example

Exception Scenario :


Similar Method :

  • N/A

Suggested Reading List :

References :