解题思路:
Character.isDigit()方法和String.matches()
public static void main(String[] args) {
String str = "123458766";
// System.out.println(str.matches("[0-9]+"));
System.out.println(checkIsDigit("868763"));
}
public static boolean checkIsDigit(String str){
char[] chars = str.toCharArray();
for(int i = 0 ;i < chars.length; i++){
if(!Character.isDigit(chars[i])){
return false;
}
}
return true;
}