Java StringBuilder codePointBefore() Method
Example
Return the Unicode value of the character before index 1:
StringBuilder sb = new StringBuilder("Hello");
int result = sb.codePointBefore(1);
System.out.println(result);
Definition and Usage
The codePointBefore() method returns the Unicode value (code point) of the character before the specified index.
The index of the first character is 0, so the character before index 1 is the first character.
Syntax
public int codePointBefore(int index)
Parameter Values
| Parameter | Description |
|---|---|
| index | Required. An int value representing the index after the character. |
Technical Details
| Returns: | An int value, representing the Unicode value of the character before the index. |
|---|---|
| Throws: | IndexOutOfBoundsException - if index is less than 1 or larger than the length. |
Related Pages
Java String codePointBefore() Method
❮ StringBuilder Methods