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";

  1. Abdul Shameer on 2016-1-5

    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;

  2. Apurv Dubey on 2017-4-15

    this is about character in a string and not whole string. For ex: “`Character.isDigit(“hello1world”.charAt(5))“` returns true

Leave a comment