Character-oriented utility methods
Character serves as a repository for character-oriented utility methods. Examples of those methods include:
- public static boolean isDigit(char c), which returns a Boolean true value if c's character is a digit. Otherwise, false returns.
- public static boolean isLetter(char c), which returns a Boolean true value if c's character is a letter. Otherwise, false returns.
- public static boolean isUpperCase(char c), which returns a Boolean true value if c's character is an uppercase letter. Otherwise, false returns.
- public static char toLowerCase(char c), which returns the lowercase equivalent of c's character if it is uppercase. Otherwise c's character returns.
- public static char toUpperCase(char c), which returns the uppercase equivalent of c's character if it is lowercase. Otherwise c's character returns.
The following code fragment demonstrates those five methods:
System.out.println (Character.isDigit ('4')); // Output: true
System.out.println (Character.isLetter (';')); // Output: false
System.out.println (Character.isUpperCase ('X')); // Output: true
System.out.println (Character.toLowerCase ('B')); // Output: b
System.out.println (Character.toUpperCase ('a')); // Output: A
No comments:
Post a Comment