Home »
Java programming language
Java Character.UnicodeBlock forName() method with example
Character.UnicodeBlock Class forName() method: Here, we are going to learn about the forName() method of Character.UnicodeBlock Class with its syntax and example.
Submitted by Preeti Jain, on December 13, 2019
Character.UnicodeBlock Class forName() method
- forName() method is available in java.lang package.
- forName() method is used to retrieve the name of Unicode block which is calculated by the Unicode Standards.
-
There are some rules to define the block name:
- All spaces deleted by Unicode Standard by default.
- Every constant UnicodeBlock identifier is text represented.
- forName() 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.
- forName() method is a final method it does not override in child class.
-
forName() method may throw an exception at the time of returning Unicode block,
- IllegalArgumentException: This exception may throw when the given argument value is not valid.
- NullPointerException: This exception may throw when the given argument value is null.
Syntax:
public static final Character.UnicodeBlock forName(String bl_name);
Parameter(s):
- String bl-name – represents the name of Unicode Block.
Return value:
The return type of this method is Character.UnicodeBlock, it returns the Unicode Block instance indicated by the given parameter bl_name(block name).
Example:
// Java program to demonstrate the example
// of Character.UnicodeBlock forName(String bl_name)
// method of Character.UnicodeBlock class
public class ForName {
public static void main(String args[]) {
// By using forName() method is to return the UnicodeBlock instance
// of the given block name
Character.UnicodeBlock ub1 = Character.UnicodeBlock.forName("MYANMAR");
Character.UnicodeBlock ub2 = Character.UnicodeBlock.forName("LIMBU");
Character.UnicodeBlock ub3 = Character.UnicodeBlock.forName("MONGOLIAN");
Character.UnicodeBlock ub4 = Character.UnicodeBlock.forName("OGHAM");
Character.UnicodeBlock ub5 = Character.UnicodeBlock.forName("limbu");
// Display UnicodeBlock instance
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 = MYANMAR
ub2 = LIMBU
ub3 = MONGOLIAN
ub4 = OGHAM
ub5 = LIMBU