}
Lz满意不 ------其他解决方案-------------------- public static void main(String[] args) {
String str = "今天是2012人头,现147在事1月5号";
char c ;
int length = str.length();
System.out.println(length);
String str1 = "";
List list = new ArrayList();
for(int i = 0;i<length;i++){
System.out.println(i);
c = str.charAt(i);
}
System.out.println(list);
} ------其他解决方案-------------------- System.out.println("输入一个字符串:");
Scanner scanner = new Scanner(System.in);
StringBuffer sb=new StringBuffer();
String line = scanner.nextLine();
char a[]=line.toCharArray();
System.out.println("打印出其中所有的数字:");
for (int i = 0; i < a.length; i++)
{
if(Character.isDigit(a[i]))
sb.append(a[i]);
}
System.out.println(sb);
------其他解决方案-------------------- public static void main(String[] args) {
String str = "今天是2012人头,现147在事1月5号";
char c ;
int length = str.length();
System.out.println(length);
String str1 = "";
List list = new ArrayList();
for(int i = 0;i<length;i++){
System.out.println(i);
c = str.charAt(i);