I am new to using lambdas and streams. I am trying to print an ArrayList that is sorted with duplicates removed, and formatted. I know that the following will work:
list.stream().distinct().forEach(System.out::print);
That will produce an output of ADFJKLXZ or whatever random Characters I have in list. However, what I want my output to look like is A, D, F, J, K, L, X, Z
I have tried this:
list.stream().distinct().forEach(System.out::printf("%s, ", ));
I think I probably still have some confusion on :: Why doesn't the above code work and what do I do to fix it?