- Java.lang Package classes
- Java.lang - Home
- Java.lang - Boolean
- Java.lang - Byte
- Java.lang - Character
- Java.lang - Character.Subset
- Java.lang - Character.UnicodeBlock
- Java.lang - Class
- Java.lang - ClassLoader
- Java.lang - Compiler
- Java.lang - Double
- Java.lang - Enum
- Java.lang - Float
- Java.lang - InheritableThreadLocal
- Java.lang - Integer
- Java.lang - Long
- Java.lang - Math
- Java.lang - Number
- Java.lang - Object
- Java.lang - Package
- Java.lang - Process
- Java.lang - ProcessBuilder
- Java.lang - Runtime
- Java.lang - RuntimePermission
- Java.lang - SecurityManager
- Java.lang - Short
- Java.lang - StackTraceElement
- Java.lang - StrictMath
- Java.lang - String
- Java.lang - StringBuffer
- Java.lang - StringBuilder
- Java.lang - System
- Java.lang - Thread
- Java.lang - ThreadGroup
- Java.lang - ThreadLocal
- Java.lang - Throwable
- Java.lang - Void
- Java.lang Package extras
- Java.lang - Interfaces
- Java.lang - Errors
- Java.lang - Exceptions
- Java.lang Package Useful Resources
- Java.lang - Useful Resources
- Java.lang - Discussion
Java.lang.Character.codePointBefore() Method
Description
The java.lang.Character.codePointBefore(CharSequence seq, int index) returns the code point preceding the given index of the CharSequence. If the char value at (index - 1) in the CharSequence is in the low-surrogate range, (index - 2) is not negative, and the char value at (index - 2) in the CharSequence is in the high-surrogate range, then the supplementary code point corresponding to this surrogate pair is returned.
Otherwise, the char value at (index - 1) is returned.
Declaration
Following is the declaration for java.lang.Character.codePointBefore() method
public static int codePointBefore(CharSequence seq, int index)
Parameters
seq − the CharSequence instance
index − 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
NullPointerException − if a is null.
IndexOutOfBoundsException − if the index argument is less than 1 or greater than seq.length()
Example
The following example shows the usage of lang.Character.codePointBefore() method.
package com.tutorialspoint; import java.lang.*; public class CharacterDemo { public static void main(String[] args) { // create a CharSequence seq and assign value CharSequence seq = "Hello"; // create and assign value to index int index = 4; // create an int res int res; // assign result of codePointBefore on seq at index to res res = Character.codePointBefore(seq, index); String str = "Unicode code point is " + res; // print res value System.out.println( str ); } }
Let us compile and run the above program, this will produce the following result −
Unicode code point is 108