Java: Print a unique character in a string

前端 未结 17 1415
长情又很酷
长情又很酷 2021-01-03 00:03

I\'m writing a program that will print the unique character in a string (entered through a scanner). I\'ve created a method that tries to accomplish this but I keep getting

17条回答
  •  一个人的身影
    2021-01-03 00:55

    public static String input = "10 5 5 10 6 6 2 3 1 3 4 5 3";
    
    public static void uniqueValue (String numbers) {
        String [] str = input.split(" ");
        Set  unique = new HashSet  (Arrays.asList(str));
        System.out.println(unique);
    
        for (String value:unique) {
            int count = 0;
            for ( int i= 0; i

提交回复
热议问题