Java Character.UnicodeBlock forName()方法与示例

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值