Java2all.com  

Character





Share This Topic -

Character class :

The Character class encapsulates a char value. This class provides the following constructor.

Character(char ch)

Here, c is a char value. charValue() method returns the char value that is encapsulated by a Character object and has the following form:

char charValue()

EX :

 import java.util.*;

public class Char_Demo
{
	public static void main(String args[])
	{
		Character c1 = new Character('m');
		char c2 = 'O';
		System.out.println("Object C1 = " + c1);
		System.out.println("char value of Character Object = " + c1.charValue());
		System.out.println(c2 + " is defined character set ? " + Character.isDefined(c2));
		System.out.println("c2 is digit = " + Character.isDigit(c2));
		System.out.println("c2 is lowercase character = " + Character.isLowerCase(c2));
		System.out.println("c2 is uppercase character = " + Character.isUpperCase(c2));
		
		
	}
}

 
Output :
 
Object C1 = m
char value of Character Object = m
O is defined character set ? true
c2 is digit = false
c2 is lowercase character = false
c2 is uppercase character = true