java.lang.Character isDefined(int codePoint)

Description

The Character.isDefined(int codePoint) java method 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.

The isDefined(int codePoint) method of Character class is static thus it should be accessed statically which means the we would be calling this method in this format:

Character.isDefined(int codePoint)

Non static method is usually called by just declaring method_name(argument) however in this case since the method is static, it should be called by appending the class name as suffix. We will be encountering a compilation problem if we call the java isDefined() method non statically.

Method Syntax

public static boolean isDefined(int codePoint)

Method Argument

Data Type Parameter Description
int codePoint the character (Unicode code point) to be tested.

Method Returns

The isDefined(int codePoint) method of Character class returns true if the character has a defined meaning in Unicode; false otherwise.

Compatibility

Requires Java 1.5 and up

Java Character isDefined(int codePoint) Example

Below is a simple java example on the usage of isDefined(int codePoint) method of Character class.

package com.javatutorialhq.java.examples;

/*
 * This example source code demonstrates the use of 
 * isDefined(int codePoint) method of Character class.
 */

public class CharacterIsDefinedCodepointExample {

	public static void main(String[] args) {

		// initialize a codepoint
		int codepoint = 51;

		// check if the codepoint is defined in Unicode
		boolean checkBool = Character.isDefined(codepoint);
		// print result
		if (checkBool) {
			System.out.print("Codepoint '" +
					codepoint + "' is defined in Unicode");
		} else {
			System.out.print("Codepoint '" + 
					codepoint + "' is defined in Unicode");
		}

	}

}

Sample Output

Below is the sample output when you run the above example.

java Character isDefined(int codePoint) example output