- public static void main(String[] args) {
- char[] chs = { 'a', 'b', 'a', 'c', 'c', 'e', 'b' };
- String a = new String(chs);
- while (a.length() != 0) {
- int sum = 0;
- int x = 0;
- String b = String.valueOf(a.charAt(x));
- for (int y = 0; y < a.length(); y++) {
- if (a.contains(b)) {
- sum++;
- y--;
- a = a.replaceFirst(b, "");
- }
- }
- System.out.println(b + "出现次数是:" + sum);
- }
- }
复制代码 今天在看String,就转换成String做了做{:soso_e113:}
|