-1

so I all I want for this to do is to print out the chars instead of the ascii values...

     str.chars()
        .distinct()
        .forEach(System.out::println);

this is the output:

     97
     98
     99
     100

does anyone know how to fix this?

2 Answers2

1

You can map the characters accordingly using the mapToObj method

str.chars().mapToObj(c -> (char)c).forEach(System.out::println);

Aneesh
  • 148
  • 1
  • 10
0

You can do this by casting the int to char as below

str.chars()
        .distinct()
        .forEach(x -> System.out.println((char)x));
Gaurav Jeswani
  • 4,410
  • 6
  • 26
  • 47