Java.lang.Character.isDefined() Method



Description

The java.lang.Character.isDefined(int codePoint) determines if a character (Unicode code point) is defined in Unicode.

A character is defined if at least one of the following is true −

  • It has an entry in the UnicodeData file.
  • It has a value in a range defined by the UnicodeData file.

Declaration

Following is the declaration for java.lang.Character.isDefined() method

public static boolean isDefined(int codePoint)

Parameters

codePoint − the character (Unicode code point) to be tested

Return Value

This method returns true if the character has a defined meaning in Unicode, false otherwise.

Exception

NA

Example

The following example shows the usage of lang.Character.isDefined() method.

package com.tutorialspoint;

import java.lang.*;

public class CharacterDemo {

   public static void main(String[] args) {

      // create a int primitive cp
      int cp;

      // assign values to cp
      cp = 0x012345;

      // create a boolean primitives b
      boolean b;

      // assign isDefined result of cp to b
      b = Character.isDefined(cp);

      String str = "cp has defined meaning in Unicode is " + b;

      // print b value
      System.out.println( str );
   }
}

Let us compile and run the above program, this will produce the following result −

cp has defined meaning in Unicode is true
java_lang_character.htm
Advertisements