title: Map one object to multiple objects in java stream
body: <p>I have a list of unique longs. I would like to create a piece of code, which takes the list as an input and returns as a result a list of pairs which combines every element with each other excluding the same element, for example:</p>
  
  <blockquote>
    <p>[1,2,3] -> [(1,2),(1,3),(2,1),(2,3),(3,1),(3,2)]</p>
  </blockquote>
  
  <p>Is it possible to to this using Java Stream API?
  I tried something like this:</p>
  
  <pre><code>List&lt;Pair&lt;Long, Long&gt;&gt; result = myLongsList.stream().map(firstLong -&gt;
          myLongsList.stream()
                  .filter(secondLong -&gt; !Objects.equals(firstLong, secondLong))
                  .map(secondLong-&gt; Pair.of(firstLong, secondLong))
                  .collect(????))
              .collect(toList());
  </code></pre>
  
  <p>Is it possible to write the collector or change anything in the code above for it to return the results desired?
  I can of course to this with nested for loop, but I was wondering if I can do this with stream API.</p>