import java.util.ArrayList; import java.util.List;//char *str = "AbcABca"; //写出一个函数,查找出每个字符的个数,区分大小写 public class Find { public static void main(String args[]) { char[] str = { 'A', 'b', 'c', 'A
import java.util.List;//char *str = "AbcABca";
//写出一个函数,查找出每个字符的个数,区分大小写
public class Find { public static void main(String args[]) {
char[] str = { 'A', 'b', 'c', 'A', 'B', 'c', 'a' };
List<Character> list = new ArrayList<Character>();
for (int i = 0; i < str.length; i++) {
int num = 1;
for (int j = i + 1; j < str.length; j++) {
if (str[j] == str[i])
num++; }
if (!list.contains(str[i]))
System.out.println(str[i] + " " + num);
list.add(str[i]);
} }
}