0% found this document useful (0 votes)
7 views2 pages

Java Character Class Methods Explained

The document explains the char data type in Java, which is a 16-bit unsigned primitive type representing Unicode characters. It details the range of char values and provides examples of character literals, as well as methods from the Character class for manipulating characters, such as isUpperCase() and toLowerCase(). Additionally, it includes a demo class showcasing the use of these methods with various character inputs.

Uploaded by

richify001
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views2 pages

Java Character Class Methods Explained

The document explains the char data type in Java, which is a 16-bit unsigned primitive type representing Unicode characters. It details the range of char values and provides examples of character literals, as well as methods from the Character class for manipulating characters, such as isUpperCase() and toLowerCase(). Additionally, it includes a demo class showcasing the use of these methods with various character inputs.

Uploaded by

richify001
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

CHARACTER CLASS IN JAVA

 The char data type is a 16-bit unsigned Java primitive data type.
 It represents a Unicode character.
 Note that char is an unsigned data type. Therefore, a char variable cannot have a negative value.
 A character literal represents a value of the char data type.
 A char literal is a single(one) character enclosed in single quote marks.
 The range of the char data type is 0 to 65535, which is the same as the range of the Unicode set.
 A char is a single character, that is a letter, a digit, a symbol, a tab, a space, or something similar.

e.g. char c = ‘d'; char c1 = 'A'; char c2 = '\t'; char c3 = '5'; char c4 = '/';
char c5=' '; char c6='\n'; char c7='\0' char c8='\\'

In Java Character class is available in [Link] package & methods of this class are used to
manipulate character/ elements of a char array.

Methods of Character class:


1. isUpperCase()
2. isLowerCase()
3. isDigit()
4. isLetter()
5. isLetterOrDigit()
6. isWhitespace() Convertor
7. toUpperCase()
8. toLowerCase()

Process to invoke functions/methods of Character class


[Link]()
Class Function/method
Separator

Definitions:
1) isUpperCase(char) :
 It returns true if character argument is an uppercase /a capital letter, otherwise returns false.
 It returns a boolean result.
2) isLowerCase(char) :
 It returns true if character argument is a lowercase /small letter, otherwise returns false.
 It returns a boolean result.
3) isDigit(char) :
 It returns true if character argument is a digit, otherwise returns false.
 It returns a boolean result.
4) isLetter(char) :
 It returns true if character argument is a letter, otherwise returns false.
 It returns a boolean result.
5) isLetterOrDigit(char) :
 It returns true if character argument is a letter or digit, otherwise returns false.
 It returns a boolean result.
6) isWhitespace(char) :
 It returns true if character argument is a white space /blank space, otherwise returns false.
 It returns a boolean result.
7) toUpperCase(char) :
 This function converts the character argument into uppercase letter /capital letter.
 It returns a character result.
8) toLowerCase(char) :
 This function converts the character argument into lower letter /small letter.
 It returns a character result.

class demo
{
public static void main( )
{
char ch[ ]={'d','A','8',' ','g'};
[Link]([Link](ch[2])); false
[Link]([Link](ch[4])); true
[Link]([Link](ch[2])); true
[Link]([Link](ch[1])); true
[Link]([Link](ch[2])); true
[Link]([Link](ch[3])); true
[Link]([Link](ch[0])); D
[Link]([Link](ch[1])); a
[Link]([Link](ch[2])); 8

[Link]([Link](ch[1])); A

}}

*******

You might also like