Character.UnicodeBlock类的forName()方法 (Character.UnicodeBlock Class forName() method)
forName() method is available in java.lang package.
forName()方法在java.lang包中可用。
forName() method is used to retrieve the name of Unicode block which is calculated by the Unicode Standards.
forName()方法用于检索由Unicode标准计算的Unicode块的名称。
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()方法是一个静态方法,可以使用类名进行访问,如果尝试使用类对象访问该方法,则不会出现任何错误。
forName() method is a final method it does not override in child class.
forName()方法是最终方法,不会在子类中覆盖。
forName() method may throw an exception at the time of returning Unicode block,
forName()方法在返回Unicode块时可能会引发异常,
- IllegalArgumentException: This exception may throw when the given argument value is not valid.IllegalArgumentException :当给定的参数值无效时,可能引发此异常。
- NullPointerException: This exception may throw when the given argument value is null.NullPointerException :当给定参数值为null时,可能引发此异常。
Syntax:
句法:
public static final Character.UnicodeBlock forName(String bl_name);
Parameter(s):
参数:
String bl-name – represents the name of Unicode Block.
字符串bl-name –表示Unicode块的名称。
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).
此方法的返回类型为Character.UnicodeBlock ,它返回由给定参数bl_name(block name)指示的Unicode Block实例。
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
翻译自: https://www.includehelp.com/java/character-unicodeblock-forname-method-with-example.aspx