2 thoughts on “Check a character in a String is number or not in Java”

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

  2. It could be easy to do as follows:


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

Leave a Comment