Java String.codePointBefore(int index)

Syntax

String.codePointBefore(int index) has the following syntax.

public int codePointBefore(int index)

Example

In the following code shows how to use String.codePointBefore(int index) method.


public class Main {
/*  ww w .  ja v  a 2 s  .c  om*/
  public static void main(String[] args) {
  
    String str = "java2s.com";
    System.out.println("String = " + str);
        
    // codepoint before index 1 i.e j
    int retval = str.codePointBefore(1);
        
    // prints character before index1 in string
    System.out.println("Character(unicode point) = " + retval);
  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.lang »




Boolean
Byte
Character
Class
Double
Enum
Float
Integer
Long
Math
Number
Object
Package
Process
ProcessBuilder
Runnable
Runtime
SecurityManager
Short
StackTraceElement
StrictMath
String
StringBuffer
StringBuilder
System
Thread
ThreadGroup
ThreadLocal
Throwable