As the answers indicate (if you examine them carefully!), your question is ambiguous. What do you mean by "an A-z letter" or a digit?
If you want to know if a character is a Unicode letter or digit, then use the Character.isLetter
and Character.isDigit
methods.
If you want to know if a character is an ASCII letter or digit, then the best thing to do is to test by comparing with the character ranges 'a' to 'z', 'A' to 'Z' and '0' to '9'.
Note that all ASCII letters / digits are Unicode letters / digits ... but there are many Unicode letters / digits characters that are not ASCII. For example, accented letters, cyrillic, sanskrit, ...
The general solution is to do this:
Character.UnicodeBlock block = Character.UnicodeBlock.of(someCodePoint);
and then test to see if the block is one of the ones that you are interested in. In some cases you will need to test for multiple blocks. For example, there are (at least) 4 code blocks for Cyrillic characters and 7 for Latin. The Character.UnicodeBlock
class defines static constants for well-known blocks; see the javadocs.
Note that any code point will be in at most one block.