Primitive character
You will use primitive character most of the time for a single character value.
Arithmetic operation on character
In java, char
is an unsigned 16-bit integer that represents a ASCII character. More about character literal on Character literal.
a
The Unicode numerical value for lower case letter ‘a’ is 97.
When you perform arithmetic operations on characters, you are actually performing arithmetic on their ASCII value.
1
In the below code, ch
has a value of ‘a’, which has an equivalent ASCII value of 97, when we increment the value, it represents a different character.
b
Character wrapper class
Back to parent page: Java Standard Edition (Java SE) and Java Programming
Web_and_App_DevelopmentProgramming_LanguagesJavaCharacter
Reference: