思路: HashSet中的元素具有无序、不重复的特点,故使用HashSet存储字符串中的字符,最后输出HashSet集合长度 即为字符串中不同字符的个数。 代码: import java.util.HashSet; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (sc.hasNext()) { String line = sc.nextLine(); HashSet<Chara...