how to check if a char is a letter java 1

how to check if a char is a letter java

Character.isDigit(string.charAt(index)) //(JavaDoc) will return true if it's a digit
Character.isLetter(string.charAt(index)) //(JavaDoc) will return true if it's a letter

Here is what the above code is Doing:
1. We’re creating a variable called index and setting it to 0.
2. We’re creating a while loop that will run as long as index is less than the length of the string.
3. We’re creating an if statement that will run if the character at the index is a digit.
4. We’re creating an if statement that will run if the character at the index is a letter.
5. We’re incrementing index by 1.

Similar Posts