The Java Character.UnicodeBlock class is a family of character subsets representing the character blocks in the Unicode specification. Character blocks generally define characters used for a specific script or purpose.
Class Declaration
Following is the declaration for java.lang.Character.UnicodeBlock class −
publicstaticfinalclassCharacter.UnicodeBlockextendsCharacter.Subset
Class Methods
Sr.No. | Method & Description |
---|---|
1 | forName()This method returns the UnicodeBlock with the given name. |
2 | of()This 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. |
2 | of(int codePoint)This 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. |
Learn Java in-depth with real-world projects through our Java certification course. Enroll and become a certified expert to boost your career.
Getting UnicodeBlock using Block Names Example
The following example shows the usage of Java Character.UnicodeBlock forName() method.
Open Compiler
packagecom.tutorialspoint;publicclassCharacterUnicodeBlockDemo{publicstaticvoidmain(String[] args){// returns the UnicodeBlock instance with blockName "BASIC_LATIN"System.out.println(Character.UnicodeBlock.forName("BASIC_LATIN"));// returns the UnicodeBlock instance with blockName "BasicLatin"System.out.println(Character.UnicodeBlock.forName("BasicLatin"));// returns the UnicodeBlock instance with specified blockName System.out.println(Character.UnicodeBlock.forName("ARABIC"));System.out.println(Character.UnicodeBlock.forName("MUSICALSYMBOLS"));System.out.println(Character.UnicodeBlock.forName("TAMIL"));}}
Let us compile and run the above program, this will produce the following result −
BASIC_LATIN
BASIC_LATIN
ARABIC
MUSICAL_SYMBOLS
TAMIL
Leave a Reply