- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to find the unicode category for a given character in Java?
A Character class is a subclass of an Object and it wraps a value of the primitive type char in an object. An object of type Character contains a single field whose type is char.
We can determine the unicode category for a particular character by using the getType() method. It is a static method of Character class and it returns an integer value of char ch representing in unicode general category.
Syntax
public static int getType(char ch)
Example
public class CharacterTypeTest { public static void main(String args[]) { System.out.println("T represnts unicode category of: " + Character.getType('T')); System.out.println("@ represnts unicode category of: " + Character.getType('@')); System.out.println(") represnts unicode category of: " + Character.getType(')')); System.out.println("1 represnts unicode category of: " + Character.getType('1')); System.out.println("- represnts unicode category of: " + Character.getType('-')); System.out.println("_ represnts unicode category of: " + Character.getType('_')); System.out.println("a represnts unicode category of: " + Character.getType('a')); } }
Output
T represnts unicode category of: 1 @ represnts unicode category of: 24 ) represnts unicode category of: 22 1 represnts unicode category of: 9 - represnts unicode category of: 20 _ represnts unicode category of: 23 a represnts unicode category of: 2
Advertisements