62,567
社区成员




public static boolean checkNumber(String str) {
// return str.matches("^[\\d]+$");
try{
Long.parseLong(str);
}catch(Exception e){
return false;
}
return true;
}
public static void main(String[] args) {
String str = "2345768947376822331981";
if(checkNumber(str)){
System.out.println("true");
}else{
System.out.println("false");
}
}
public class isNumeric{
puclic static void main(String[] args){
String s1 = "89723457fakjhfas(*&897";
boolean question = isAllDigit(s1);
if(question){
System.out.println("是由数字组成");
}else{
System.out.println("不是由数字组成");
}
}
public static boolean isAllDigit(String num){
String s1 = num;
boolean b = true;
for(int i=0 ; i<s1.length() ; i++){
char c = s1.charAt(i);
if(c>='0' && c<='9'){
b = true;
} else{
b = fales;
break;
}
}
return b;
}
}