Is character a digit, letter, white space, lower case or upper case character
public class Main {
public static void main(String[] args) {
char a[] = { 'a', 'b', '5', '?', 'A', ' ' };
for (int i = 0; i < a.length; i++) {
if (Character.isDigit(a[i]))
System.out.println(a[i] + "is a digit ");
if (Character.isLetter(a[i]))
System.out.println(a[i] + "is a letter ");
if (Character.isWhitespace(a[i]))
System.out.println(a[i] + "is a White Space ");
if (Character.isLowerCase(a[i]))
System.out.println(a[i] + "is a lower case ");
if (Character.isLowerCase(a[i]))
System.out.println(a[i] + "is a upper case ");
}
}
}
Related examples in the same category