Java.lang.Character . isdigit() and isletter() methods

[LeetCode] – 125. The Valid Palindrome
In this problem, I encountered a new method to determine whether a string is a letter or a number. Here’s an explanation.
Use isDigit to determine if it is a number

public static boolean isNumeric(String str){
    for (int i = str.length();--i>=0;){
    if (!Character.isDigit(str.charAt(i))){
        return false;
    }
  }
  return true;
}

Use isLetter to determine if it is a letter

public class Test{
   public static void main(String args[]){
      System.out.println( Character.isLetter('c'));
      System.out.println( Character.isLetter('5'));
   }
}

Results:

 true
 false

Read More: