éè¦jdk8çæ¬
import java.util.stream.*;
/**
* @author hardneedl
*/
final class StreamDistinct {
public static void main(String... args) {
//ä»å½ä»¤è¡ä¸æ¥æ¶å¾
被åæçå符串
IntStream distinctStream = args[0].chars().distinct();
distinctStream.forEach(I->{
String s = Character.toString((char) I);
//计ç®è¿ä¸ªå符åºç°ç次æ°
long count = args[0].chars().filter(p-> p == I).count();
System.out.printf("%s\t :%d 次\r\n", s, count);
});
}
}