Here we are going to see a code sample which would help to determine if a string contains only alphabets or not. We can also find the number of alphabets it contains. So we will also look at the different ways to find alphabets in String as well as count of alphabets in the String. We have already covered the part where we saw the sample code to check How to check if String contains only numeric in Java. To do so, Java provides regular expressions using java.util.regex.Pattern and java.util.regex.Matcher class.
Complete Code Sample to check if String contains only alphabets
And the output would be :
Whats your way of String Validation? Don’t forget to mention in comments 🙂