Java.lang.Character.UnicodeBlock Class in Java

Character.UnicodeBlock Class represents particular Character blocks of the Unicode(standards using hexadecimal values to express characters – 16 bit) specifications. Character Blocks define characters used for specific purpose.

Declaration :

public static final class Character.UnicodeBlock
   extends Character.Subset

Methods of Character.UnicodeBlock Class :

  • forName() : java.lang.Character.UnicodeBlock.forName() returns the name of Unicode Blocks, which are determined by the Unicode Standards.
    The method accepts argument as Canonical Block as per Unicode Standards.
    Syntax :

    public static final Character.UnicodeBlock forName(String block)
    Parameters : 
    block : Name of UniCode Block.
    Return  :
    instance of UniCode Block.
    Exception : 
    -> IllegalArgumentException
    -> NullPointerException
  • of(char ch) : java.lang.Character.Subset.of(char ch) returns the UniCode Block having the argumented character or null if the character is not a part of any defined Unicode Block.
    Syntax :

    public static Character.UnicodeBlock of(char ch)
    Parameters : 
    ch : character to be found.
    Return  :
    returns the UniCode Block or null.
    Exception : 
    -> IllegalArgumentException
  • of(int UCPoint) : java.lang.Character.Subset.of(int UCPoint)returns the object having the argumented UniCode – Point or null if the character is not a part of any defined Unicode Block.
    Syntax :

    public final String toString()
    Parameters : 
    Return  :
    returns the object having the argumented UniCode - Point or null
    Exception : 
    -> IllegalArgumentException
// Java Program illustrating the use of
// Character.UnicodeBlock class Methods.
import java.lang.*;
public class CharacterSubsetDemo 
   public static void main(String[] args) 
      // Use of forName() : 
      // returns Unicode Blocks, as per Unicode Standards
      System.out.println("Using UnicodeBlock.forName() : ");
      System.out.println(Character.UnicodeBlock.forName("MALAYALAM") + " ");
      // Use of of(char ch) :
      System.out.println("Using UnicodeBlock.of(char ch) : ");
      System.out.println(Character.UnicodeBlock.of(' '));
      System.out.println(Character.UnicodeBlock.of('u21ac') + " ");
      // Use of(int UCPoint) : 
      System.out.println("Using UnicodeBlock.of(int UCPoint) : ");

Output :

Using UnicodeBlock.forName() : 

Using UnicodeBlock.of(char ch) : 

Using UnicodeBlock.of(int UCPoint) : 

Note :
lang.Character.UnicodeBlock Class inherits others methods from lang.Character.Subset Class class which in turn inherits methods from lang.Character.Object class.

For further details about java.lang.Object, refer :
lang.Character.Subset Class in Java.
Object class in Java.

Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.

This article is attributed to GeeksforGeeks.org

leave a comment



load comments

Subscribe to Our Newsletter