Page 77 - CTS - CSA TP - Volume 2
P. 77
COMPUTER SOFTWARE APPLICATION - CITS
TASK 4: Convert a Character to String
public class CharacterExample4 {
public static void main(String[] args) {
char ch = ‘X’;
String charString = Character.toString(ch);
System.out.println(“Character as String: “ + charString);
}
}
Output:
TASK 5: Check if a character is a Whitespace Character
public class CharacterExample5 {
public static void main(String[] args) {
char ch1 = ‘ ‘;
char ch2 = ‘A’;
System.out.println(ch1 + “ is a whitespace character: “ + Character.isWhitespace(ch1));
System.out.println(ch2 + “ is a whitespace character: “ + Character.isWhitespace(ch2));
}
}
Output:
62
CITS : IT & ITES - Computer Software Application - Exercise 91