'Character.isLetter' method is used to check whether given character is letter or not.
package com.sample.app;
public class App {
private static void printLetter(char charz) {
if(Character.isLetter(charz)) {
System.out.println("'" + charz + "' is a letter");
}else {
System.out.println("'" + charz + "' is not a letter");
}
}
public static void main(String args[]) {
printLetter('a');
printLetter('@');
printLetter('\t');
printLetter(' ');
printLetter(',');
}
}
Output
'a' is a letter
'@' is not a letter
' ' is not a letter
' ' is not a letter
',' is not a letter
You may
like
No comments:
Post a Comment