how to check the a character is alphabet or a numeric? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

how to check the a character is alphabet or a numeric?

14th Aug 2016, 9:07 AM
bassu S D
bassu S D - avatar
3 Answers
+ 5
using Character api class like char a = 'x' Character.isLetter() // return true Character.isDigit() // return false (true if it is a number) Character.isLetterOrDigit() // return true upvote if you learned something <3
14th Aug 2016, 2:09 PM
One_Majed
+ 2
You can aproch this multiple ways. I dont know if there is a char funktion for this. but what will work is if((int) x >= 48 && (int) x <=58) is numeric else not this os converting them in to ascii numbers. You can also test if its a 1 2 3 4 5 6 7 8 9 0.
14th Aug 2016, 10:30 AM
Eric Zeus
Eric Zeus - avatar
+ 1
sorry. . (enter your character her) ex. char a = 'x'; Character.isLetter(a)
14th Aug 2016, 2:10 PM
One_Majed