Java Data Type Tutorial - Java Character.charCount(int codePoint)








Syntax

Character.charCount(int codePoint) has the following syntax.

public static int charCount(int codePoint)

Example

In the following code shows how to use Character.charCount(int codePoint) method.

//from   w  w w .j a  va 2s. c  o m
public class Main {

  public static void main(String[] args) {
    int cp = 0x12345;
    int res = Character.charCount(cp);

    String str1 = "It is not a valid supplementary character";
    String str2 = "It is a valid supplementary character";

    if (res == 1) {
      System.out.println(str1);
    } else if (res == 2) {
      System.out.println(str2);
    }
  }
}

The code above generates the following result.