Home » Java programming language

Java Character.UnicodeBlock of() method with example

Character.UnicodeBlock Class of() method: Here, we are going to learn about the of() method of Character.UnicodeBlock Class with its syntax and example.
Submitted by Preeti Jain, on December 13, 2019

Character.UnicodeBlock Class of() method

  • of() method is available in java.lang package.
  • of() method is used to return the Unicode block containing the given parameter value or it returns null when the given char value is not a part of a defined Unicode Block.
  • of() method is a static method, it is accessible with the class name and if we try to access the method with the class object then we will not get any error.
  • of() method does not throw an exception at the time of returning Unicode block.

Syntax:

    public static Character.UnicodeBlock of(Char value);

Parameter(s):

  • Char value – represents the character value.

Return value:

The return type of this method is Character.UnicodeBlock, it returns the following values based on the given cases,

  • It returns the Unicode Block when the given char value is a part of any defined Unicode block.
  • It returns null when the given char value is not a part of any defined Unicode code block.

Example:

// Java program to demonstrate the example 
// of Character.UnicodeBlock of(Char value)
// method of Character.UnicodeBlock class

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

        // By using of(Char ch) method is to return the UnicodeBlock name
        // containing the given char value
        Character.UnicodeBlock ub1 = Character.UnicodeBlock.of('+');
        Character.UnicodeBlock ub2 = Character.UnicodeBlock.of('u');
        Character.UnicodeBlock ub3 = Character.UnicodeBlock.of('/');
        Character.UnicodeBlock ub4 = Character.UnicodeBlock.of('a');
        Character.UnicodeBlock ub5 = Character.UnicodeBlock.of('A');

        // Display UnicodeBlock name
        System.out.println("ub1 = " + ub1);
        System.out.println("ub2 = " + ub2);
        System.out.println("ub3 = " + ub3);
        System.out.println("ub4 = " + ub4);
        System.out.println("ub5 = " + ub5);
    }
}

Output

ub1 = BASIC_LATIN
ub2 = BASIC_LATIN
ub3 = BASIC_LATIN
ub4 = BASIC_LATIN
ub5 = BASIC_LATIN


Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.