Character.isDefined() in Java

Character.isDefined(): This method is available in java.lang.Character class of Java.

Approach 1: When the argument is of type int.

Syntax:

boolean java.lang.Character.isDefined(int codePoint)

This method takes one argument of type int as its parameter. This 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:

1. It has an entry in the UnicodeData file.

2. It has a value in a range defined by the UnicodeData file.

Parameters: One parameter is required for this method.

codePoint: the character (Unicode code point) to be tested.

Returns: true if the character has a defined meaning in Unicode; false otherwise.

Exceptions: NA

Approach

Java

public class CharacterisDefinedint {
    public static void main(String[] args) {

        int codePoint = 25;
        System.out.println(Character.isDefined(codePoint));
    }
}

Output:

true


Approach 2: When the argument is of type char.

Syntax:

boolean java.lang.Character.isDefined(char ch)

This method takes one argument of type char as its parameter. This method determines if a character is defined in Unicode.

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

1. It has an entry in the UnicodeData file.

2. It has a value in a range defined by the UnicodeData file.

Parameters: One parameter is required for this method.

ch: the character to be tested.

Returns: true if the character has a defined meaning in Unicode; false otherwise.

Exceptions: NA

Java

public class CharacterisDefinedchar {
    public static void main(String[] args) {

        char ch = 'a';
        System.out.println(Character.isDefined(ch));
    }
}

Output:

true

No comments:

Post a Comment