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