To store a single a single character we use char data type. The character has to be surrounded by single quotes, for example 'x'.
To create a character data type we do the following
char sex = 'm';
char sex = 'f';
m and f refer to male and female
Character Methods
toString(char char);
This method takes character value and returns a String object , which is, a one-character string.
String myChar=Character.toString('x');
System.out.println(myChar);
toLowerCase(char c);
This method takes in argumment of type char and return it to Lower case.
System.out.println(toLowerCase('c'));
toUpperCase(char c);
This method takes in argumment of type char and return it to upper case.
System.out.println(toUpperCase('c');
isLetter(char ch);
This method takes in char argument and returns a Boolean whether is the argument true or not.
public class CharTest {
public static void main(String args[]) {
System.out.println(Character.isLetter('#'));
System.out.println(Character.isLetter('x'));
}
}