Given a string, the task is to check whether a string contains only alphabets or not using ASCII values in JAVA.
Input : GeeksforGeeks Output : True Input : Geeks4Geeks Output : False Input : null Output : False
In this article, the characters of the string are checked one by one using their ASCII values.
- Get the string
- Match the string:
- Check if the string is empty or not. If empty, return false
- Check if the string is null or not. If null, return false.
- If the string is neither empty nor null, then check the string characters one by one for alphabet using ASCII values.
- Return true if matched
Program: Checking for String containing only Alphabets
Test Case 1: Input: GeeksforGeeks Output: true Test Case 2: Input: Geeks4Geeks Output: false Test Case 3: Input: null Output: false Test Case 4: Input: Output: false
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Check if a string contains only alphabets in Java
- Check if a string contains only alphabets in Java using Regex
- Check if a string contains only alphabets in Java using Lambda expression
- Convert a string to hexadecimal ASCII values
- Average of ASCII values of characters of a given string
- Program to find the XOR of ASCII values of characters in a string
- Count characters in a string whose ASCII values are prime
- Split a given string into substrings of length K with equal sum of ASCII values
- Program to find the product of ASCII values of characters in a string
- Count of alphabets having ASCII value less than and greater than k
- Count and Print the alphabets having ASCII value in the range [l, r]
- Count and Print the alphabets having ASCII value not in the range [l, r]
- Check if count of Alphabets and count of Numbers are equal in the given String
- Sums of ASCII values of each word in a sentence
- Map function and Dictionary in Python to sum ASCII values
- Count the number of words having sum of ASCII values less than and greater than k
- Minimize ASCII values sum after removing all occurrences of one character
- Print each word in a sentence with their corresponding average of ASCII values
- Find the sum of the ascii values of characters which are present at prime positions
- Decode an Encoded Base 64 String to ASCII String
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.