Java.lang.StringBuffer.codePointBefore() Method
Advertisements
Description
The java.lang.StringBuffer.codePointBefore() method returns the character (Unicode code point) before the specified index.The index refers to char values (Unicode code units) and ranges from 1 to length().
Declaration
Following is the declaration for java.lang.StringBuffer.codePointBefore() method
public int codePointBefore(int index)
Parameters
index -- This is the index following the code point that should be returned.
Return Value
This method returns the Unicode code point value before the given index.
Exception
NA
Example
The following example shows the usage of java.lang.StringBuffer.codePointBefore() method.
package com.tutorialspoint;
import java.lang.*;
public class StringBufferDemo {
public static void main(String[] args) {
StringBuffer buff = new StringBuffer("TUTORIALS");
System.out.println("buffer = " + buff);
// returns the codepoint before index 3
int retval = buff.codePointBefore(3);
System.out.println("Character(unicode point) = " + retval);
buff = new StringBuffer("amrood admin ");
System.out.println("buffer = " + buff);
// returns the codepoint before index 6
retval = buff.codePointBefore(6);
System.out.println("Character(unicode point) = " + retval);
}
}
Let us compile and run the above program, this will produce the following result:
buffer = TUTORIALS Character(unicode point) = 84 buffer = amrood admin Character(unicode point) = 100