All you need is this simple function in java.lang package.
Character.isDigit(c) |
Of course, if want to check a character in a string, need to get the char first by using the following.
str.charAt(i) |
All you need is this simple function in java.lang package.
Character.isDigit(c) |
Of course, if want to check a character in a string, need to get the char first by using the following.
str.charAt(i) |
this is about character in a string and not whole string. For ex: “`Character.isDigit(“hello1world”.charAt(5))“` returns true
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;
}