The first way to use the functions that come with java
public static boolean isNumeric(String str){ for(i<str.length();--i>=0;){ if(!Character.isDigit(str.CharAt(i))){ return false; } } return true; }
The second uses regular expressions
public static boolean isNumeric(String str){ Pattern pattern = Pattern.compile("[0-9]*"); return pattern.matcher(str).matches(); }