网上看到的一个题目,还是编编吧~不然都忘了!我的代码如下,写的不好~有毛病请指正 代码如下: public static void main (String args[]) { Tlty test = new Tlty(); String details = "123654547878564sdfsdfsf56456464646"; test.exeComputer(details); } private int rexStr (String pStr, String pRexIndex) { int rexCount = 0; Matcher m = Pattern.compile(pRexIndex).matcher(pStr); while (m.find()) { rexCount++; } return rexCount; } private void exeComputer (String pStr) { for (int i = 0; i < 10; i++) { System.out.println("数字" + i + "的总数是" + String.valueOf(rexStr(pStr, String.valueOf(i)))); } }