title: Java 8 Stream unique characters from array
body: <p>Trying to write a simple program that will print the unique words from an input array in <strong>Java8</strong> . For example if the input is </p>
  
  <pre><code>   String[] input = {"This", "is", "This", "not"};
  </code></pre>
  
  <p>The program should output <code>[T, h, i, s, n, o, t]</code> , the order of elements should follow the same pattern as they appear in input. My approach is to <code>split</code> the input , then <code>map</code>, <code>distinct</code> and finally <code>collect</code> it toList. But the following code is printing list of streams instead of words, what am i missing?.E.g.</p>
  
  <pre><code>String[] input = {"This", "is", "This", "not"};
         System.out.println(Arrays.stream(input)
                 .map(word -&gt; word.split(""))
                 .map(Arrays::stream)
                 .distinct()
                 .collect(toList()));
  </code></pre>
  
  <p>Current output</p>
  
  <pre><code>[java.util.stream.ReferencePipeline$Head@548c4f57, java.util.stream.ReferencePipeline$Head@1218025c, java.util.stream.ReferencePipeline$Head@816f27d, java.util.stream.ReferencePipeline$Head@87aac27]
  </code></pre>
  
  <p>I am interested to see if there are some other ways in Java8 to achieve the same. </p>