- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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
What is the character wrapper class and its methods in Java?
The Character class of the java.lang package wraps a value of the primitive datatype char. It offers a number of useful class (i.e., static) methods for manipulating characters. You can create a Character object with the Character constructor.
Character ch = new Character('a');
Following are the notable methods of the Character class.
1 | isLetter() Determines whether the specified char value is a letter. |
2 | isDigit() Determines whether the specified char value is a digit. |
3 | isWhitespace() Determines whether the specified char value is white space. |
4 | isUpperCase() Determines whether the specified char value is uppercase. |
5 | isLowerCase() Determines whether the specified char value is lowercase. |
6 |
toUpperCase() Returns the uppercase form of the specified char value. |
7 | toLowerCase() Returns the lowercase form of the specified char value. |
8 | toString() Returns a String object representing the specified character value that is, a one-character string. |
Example
public class CharacterClassExample { public static void main(String[] args) { char ch1, ch2; ch1 = '9'; ch2 = 'V'; boolean b1, b2; b1 = Character.isDigit(ch1); b2 = Character.isDigit(ch2); String str1 = ch1 + " is a digit is " + b1; String str2 = ch2 + " is a digit is " + b2; System.out.println( str1 ); System.out.println( str2 ); } }
Output
9 is a digit is true V is a digit is false
- Related Articles
- What is the number wrapper class and its methods in Java?
- What is the importance of the Throwable class and its methods in Java?
- What is Regex class and its class methods in C#?
- What is the System.Console class and its methods in C#?
- Java Float Wrapper Class
- Which packages contain Wrapper class in Java?
- What is the need of wrapper classes in Java?
- Why do we need a wrapper class in Java?
- What are Class/Static methods in Java?
- What is the use of in flush() and close() methods of BufferedWriter class in Java?
- Character Class in Java
- What are wrapper classes in Java?
- BitSet class methods in Java
- Class that contains a String instance variable and methods to set and get its value in Java
- How to convert primitive data into wrapper class using Java?
