title: Does Java SE 8 have Pairs or Tuples?
body: <p>I am playing around with lazy functional operations in Java SE 8, and I want to <code>map</code> an index <code>i</code> to a pair / tuple <code>(i, value[i])</code>, then <code>filter</code> based on the second <code>value[i]</code> element, and finally output just the indices.</p>
  
  <p>Must I still suffer this: <a href="https://stackoverflow.com/questions/156275/what-is-the-equivalent-of-the-c-pairl-r-in-java">What is the equivalent of the C++ Pair&lt;L,R&gt; in Java?</a> in the bold new era of lambdas and streams?</p>
  
  <p><strong>Update:</strong> I presented a rather simplified example, which has a neat solution offered by @dkatzel in one of the answers below. However, it does <em>not</em> generalize. Therefore, let me add a more general example:</p>
  
  <pre><code>package com.example.test;
  
  import java.util.ArrayList;
  import java.util.stream.IntStream;
  
  public class Main {
  
    public static void main(String[] args) {
      boolean [][] directed_acyclic_graph = new boolean[][]{
          {false,  true, false,  true, false,  true},
          {false, false, false,  true, false,  true},
          {false, false, false,  true, false,  true},
          {false, false, false, false, false,  true},
          {false, false, false, false, false,  true},
          {false, false, false, false, false, false}
      };
  
      System.out.println(
          IntStream.range(0, directed_acyclic_graph.length)
          .parallel()
          .mapToLong(i -&gt; IntStream.range(0, directed_acyclic_graph[i].length)
              .filter(j -&gt; directed_acyclic_graph[j][i])
              .count()
          )
          .filter(n -&gt; n == 0)
          .collect(() -&gt; new ArrayList&lt;Long&gt;(), (c, e) -&gt; c.add(e), (c1, c2) -&gt; c1.addAll(c2))
      );
    }
  
  }
  </code></pre>
  
  <p>This gives <strong>incorrect</strong> output of <code>[0, 0, 0]</code> which corresponds to the <em>counts</em> for the three columns that are all <code>false</code>. What I need are the <em>indices</em> of these three columns. The correct output should be <code>[0, 2, 4]</code>. How can I get this result?</p>