StringBuffer.offsetByCodePoints() Method
Advertisements
Description
The java.lang.StringBuffer.offsetByCodePoints() method returns the index within this sequence that is offset from the given index by codePointOffset code points.
Declaration
Following is the declaration for java.lang.StringBuffer.offsetByCodePoints() method
public int offsetByCodePoints(int index, int codePointOffset)
Parameters
index -- This is the index to be offset.
codePointOffset -- This is the offset in code points.
Return Value
This method returns the index within this sequence.
Exception
NA
Example
The following example shows the usage of java.lang.StringBuffer.offsetByCodePoints() method.
package com.tutorialspoint;
import java.lang.*;
public class StringBufferDemo {
public static void main(String[] args) {
StringBuffer buff = new StringBuffer("aawxyzaa");
System.out.println("buffer = " + buff);
// returns the index within this sequence
int retval = buff.offsetByCodePoints(1, 4);
// prints the index
System.out.println("index = " + retval);
}
}
Let us compile and run the above program, this will produce the following result:
buffer = aawxyzaa index = 5