Check a character in a String is number or not in Java

All you need is this simple function in java.lang package.


Of course, if want to check a character in a string, need to get the char first by using the following.

Category >> Basics  
If you want someone to read your code, please put the code inside <pre><code> and </code></pre> tags. For example:
String foo = "bar";
  • Abdul Shameer

    It could be easy to do as follows:

    public boolean isStringDigit(String str){
    }catch(NumberFormatException ne){
    System.out.println("In NFE ");return false;
    return true;