[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:
- How to Fix:java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/client/methods/HttpPost
- Error in idea compilation: java.lang.OutOfMemoryError Java heap space and java.lang.StackOverflowError
- java.lang.NoSuchMethodError: org.json.JSONObject.put(Java/lang/String; Java/util/Collection;) “209151;”
- Java – read all the files and folders in a certain directory and three methods to get the file name from the file path
- Java String.split () special character processing
- Java prompt unmappable character for encoding solution
- build.gradle Warming: cannot be applied to ‘(groovy.lang.Closure)’/'(java.lang.String)’
- Java:java.lang.OutOfMemoryError : GC overhead limit exceeded solution
- java.lang.UnsupportedOperationException resolvent
- Solving syntax error: unexpected character after line continuation character
- [resolved] error: Java: illegal character: ‘\ ufef’ or error: Java: class, interface or enum required
- Syntax error: unexpected character after line continuation character
- Access characteristics of construction methods in Java inheritance
- Error querying database.Cause:java.sql.SQLSyntaxErrorException:ORA-00911:invalid character
- [Solved] Flowable Start Error: ClassCastException: java.time.LocalDateTime cannot be cast to java.lang.String
- [Solved] Sqoop Mysqltohive error: Error: java.lang.RuntimeException: java.lang.RuntimeException…
- Cause: java.sql.SQLException: Error setting driver on UnpooledDataSource. Cause: java.lang.ClassNot
- Failed to convert value of type ‘java.lang.String‘ to required type ‘java.util.Date‘;
- Android appears java.lang.NoClassDefFoundError A solution to the error
- Realize the simplest recursive call, simulate exception in thread “main” java.lang.stackoverflowerror exception