Java Examples - String unicode


Advertisements


Problem Description

How to determine the Unicode code point in string ?

Solution

This example shows you how to use codePointBefore() method to return the character (Unicode code point) before the specified index.

public class StringUniCode {
   public static void main(String[] args) {
      String test_string = "Welcome to TutorialsPoint";
      System.out.println("String under test is = "+test_string);
      
      System.out.println("Unicode code point at" 
         +" position 5 in the string is = "
         +  test_string.codePointBefore(5));
   }
}

Result

The above code sample will produce the following result.

String under test is = Welcome to TutorialsPoint
Unicode code point at position 5 in the string is =111

java_strings.htm

Advertisements