Java Character.UnicodeBlock of(char c) Method
Description
The Java Character.UnicodeBlock of(char c) method returns the object representing the Unicode block containing the given character, or null if the character is not a member of a defined block.
Declaration
Following is the declaration for java.lang.Character.UnicodeBlock.of() method
public static Character.UnicodeBlock of(char c)
Parameters
c − This is the character.
Return Value
This method returns the UnicodeBlock instance representing the Unicode block of which this character is a member, or null if the character is not a member of any Unicode block.
Exception
NA
Getting UnicodeBlock of BASIC_LATIN Example
The following example shows the usage of Java Character.UnicodeBlock of() method. We're using of() method to get UnicodeBlock of BASIC_LATIN using - and =.
package com.tutorialspoint;
public class CharacterUnicodeBlockDemo {
public static void main(String[] args) {
/* returns the object representing the Unicode block containing
the given character */
System.out.println(Character.UnicodeBlock.of('-'));
System.out.println(Character.UnicodeBlock.of('='));
}
}
Let us compile and run the above program, this will produce the following result −
BASIC_LATIN BASIC_LATIN
Getting UnicodeBlock of CURRENCY_SYMBOLS Example
The following example shows the usage of Java Character.UnicodeBlock of() method. We're using of() method to get UnicodeBlock of CURRENCY_SYMBOLS using unicode.
package com.tutorialspoint;
public class CharacterUnicodeBlockDemo {
public static void main(String[] args) {
/* returns the object representing the Unicode block containing
the given character */
System.out.println(Character.UnicodeBlock.of('\u20ac'));
}
}
Let us compile and run the above program, this will produce the following result −
CURRENCY_SYMBOLS
Getting UnicodeBlock of BASIC_LATIN Example
The following example shows the usage of Java Character.UnicodeBlock of() method. We're using of() method to get UnicodeBlock of BASIC_LATIN using char Z.
package com.tutorialspoint;
public class CharacterUnicodeBlockDemo {
public static void main(String[] args) {
/* returns the object representing the Unicode block containing
the given character */
System.out.println(Character.UnicodeBlock.of('Z'));
}
}
Let us compile and run the above program, this will produce the following result −
BASIC_LATIN