Java Character Class

In this article we are reading about Java Character Class.
The Character class simply a wrapper class for the primitive type char. It wraps the char primitive value to an object. An object of type Character contains a single field whose type is char. So what would be the benefit if wraps around the primitive data type to an object? Well basically we would be able to access all the methods that is readily available on the Character class which is very useful. In addition, this class provides several methods for determining a character’s category (lowercase letter, digit, etc.) and for converting characters from uppercase to lowercase and vice versa. We will go over each and every method available to Byte class thoroughly.
Character information is based on the Unicode Standard, version 6.2.0.
The methods and data of class Character are defined by the information in the UnicodeData file that is part of the Unicode Character Database maintained by the Unicode Consortium. This file specifies various properties including name and general category for every defined Unicode code point or character range.
Examples :
1
2
3
char ch = 'a'; // Char
char uniChar = '\u039A'; // Unicode for char
char[] charArray = { 'a''b''c''d''e' }; // Array of chars
Examples :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
class CharacterTest
{
public static void main(String arg[])
{
System.out.println("Checks for letter : " + Character.isLetter('M'));
System.out.println("Checks for digit : " + Character.isDigit('5'));
System.out.println("Checks for white space : " + Character.isWhitespace(' '));
System.out.println("Checks for uppercase : " + Character.isUpperCase('C'));
System.out.println("Checks for lowercase : " + Character.isLowerCase('c'));
System.out.println("Converts to uppercase : " + Character.toUpperCase('m'));
System.out.println("Converts to lowercase : " + Character.toLowerCase('Z'));
System.out.println("Converts to string : " + Character.toString('w'));
}
}
OUTPUT :
1
2
3
4
5
6
7
8
Checks for letter : true
Checks for digit : true
Checks for white space : true
Checks for uppercase : true
Checks for lowercase : true
Converts to uppercase : M
Converts to lowercase : z
Converts to string : w
So in this article we have read about “Java Character Class”.

Comments

Popular posts from this blog

Java Number Class

What are Web Resources in Microsoft Dynamics 365?