题解 | #字符个数统计#
字符个数统计
https://www.nowcoder.com/practice/eb94f6a5b2ba49c6ac72d40b5ce95f50
import java.util.HashSet; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); String str = in.nextLine(); HashSet<Character> hSet = new HashSet<Character>(); for (int i = 0; i < str.length(); i++) { char c = str.charAt(i); if (c <= 127 && c >= 0) { hSet.add(c); } } System.out.print(hSet.size()); } }