如题所述
第1个回答 2011-07-16
public class Test {
public static void main(String[] args) {
String str = "as;ldfk192301231dkk838218";
StringBuffer buff = new StringBuffer();
char[] chars = str.toCharArray();
for (int i = 0; i < chars.length; i++) {
if ('0' <= chars[i] && chars[i] <= '9') {
buff.append(chars[i]);
}
}
System.out.println(buff.toString());
}
}本回答被网友采纳
public static void main(String[] args) {
String str = "as;ldfk192301231dkk838218";
StringBuffer buff = new StringBuffer();
char[] chars = str.toCharArray();
for (int i = 0; i < chars.length; i++) {
if ('0' <= chars[i] && chars[i] <= '9') {
buff.append(chars[i]);
}
}
System.out.println(buff.toString());
}
}本回答被网友采纳