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

Character.UnicodeBlock类的()方法 (Character.UnicodeBlock Class of() method)

  • of() method is available in java.lang package.

    of()方法在java.lang包中可用。

  • 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()方法用于返回包含给定参数值的Unicode块,或者在给定char值不属于已定义Unicode块的一部分时返回null。

  • 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()方法是一个静态方法,可以使用类名进行访问,如果尝试使用类对象访问该方法,则不会出现任何错误。

  • of() method does not throw an exception at the time of returning Unicode block.

    of()方法在返回Unicode块时不会引发异常。

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,

此方法的返回类型为Character.UnicodeBlock ,它基于给定的情况返回以下值,

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

    当给定的char值是任何已定义的Unicode块的一部分时,它将返回Unicode块。

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

    当给定的char值不属于任何已定义的Unicode代码块时,它返回null。

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


翻译自: https://www.includehelp.com/java/character-unicodeblock-of-method-with-example.aspx

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值