Java Lesson9-1
Java Lesson9-1
https://blogs.ashrithgn.com/
Objectives
• In Java, single characters are represented using the data type char.
• Character constants are written as symbols enclosed in single quotes.
• Characters are stored in a computer memory using some form of
encoding.
• ASCII, which stands for American Standard Code for Information
Interchange, is one of the document coding schemes widely used today.
• Java uses Unicode Worldwide Character Standard (Unicode) , which
includes ASCII, for representing char constants.
Method Description
isDigit(ch) Returns ture if the specified character is a digit.
isLetter(ch) Returns ture if the specified character is a letter.
isLetterOrDigit(ch) Returns ture if the specified character is a letter or digit.
boolean b1 = Character.isLetter(ch);
A is letter: true
6 Faculty of Computer Science https://blogs.ashrithgn.com/
isDigit(char) Method
boolean b1 = Character.isDigit(ch);
}
}
A is digit: false
boolean b1 = Character.isLetterOrDigit(ch);
}
}
char ch = 'A';
boolean b1 = Character.isLowerCase(ch);
char ch = 'A';
boolean b1 = Character.isUpperCase(ch);
char ch = ‘A ';
boolean b1 = Character.isWhitespace(ch);
char ch = ‘A';
A is converted to A
char ch = 'A';
A is converted to a