How do I check that characters are neither letters nor numbers in Java?

So I wrote some code in Java, and I tried to find out if there was a way to write a line of code to check that the characters in the string were neither letters nor numbers I Know:

Character. Isdigit() checks for a number

and

Character. Isletter() checks a letter

But I wonder if it is possible for Java to check whether these codes exist in these codes Just like the characters in a string are "/" or "*" or even "" Same

I'm new to Java, so I don't know where to go at this point

Solution

Java provides a method for that – all you need to do is negate the result:

if (!Character.isLetterOrDigit(ch)) {
    ...
}
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>