title: Is there a function to give the output [1, 2, 3, 12, 23,...]?
body: <p>I'm trying to write a program, that handles arrays of numbers. These arrays should be a combination of these numbers, but they have to be in order.</p>
  
  <p>If I have three numbers [1, 2, 3] the arrays should be 
  [1], [2], [3], [1, 2], [1, 3], [2, 3], [1, 2, 3].</p>
  
  <p>At the moment it is working with some hardcoded for-Loops, but I can't figure out, how to do it with a function.</p>
  
  <pre><code>int numElements = 5;
  
  for (int i = 0; i &lt; numElements - 1; i++)
  {
    for (int j = i+1; j &lt; numElements; j++)
    {
      arr.add (new int[]{i, j});
    }
  }
  
  for (int i = 0; i &lt; numElements - 2; i++)
  {
    for (int j = i+1; j &lt; numElements - 1; j++)
    {
      for (int k = j + 1; k &lt; numElements; k++)
      {
        arr.add (new int[]{i, j, k});
      }
    }
  }
  </code></pre>