檢索字符的種類
package com.swun.se;
import java.util.*;
public class TestDemo{
public static void main(String args[])throws Exception{
String str = "abcdeffffffffffffffffffff";
char[] arr = str.toCharArray();
int kinds = TestDemo.countKinds(arr);
System.out.println("有"+kinds+"種字符");
}
public static int countKinds(char[] args){
Set<Character> set = new HashSet<>();
for(int i=0;i<args.length;i++){
set.add(args[i]);
}
return set.size();
}
}