title: java - find all combinations of given numbers in a given array size and store into matrix
body: <p>I am looking a way to create a matrix[][] in public static void main (String[] args), the purpose of the matrix[][]
  is store  data[] in static void combinationUtil(), the original class permutation is output like</p>
  
  <p>1 2 3 4</p>
  
  <p>1 2 3 5</p>
  
  <p>1 2 4 5</p>
  
  <p>1 3 4 5</p>
  
  <p>2 3 4 5</p>
  
  <p>what I need to to is create the matrix[][] output is the same like class permutation, it is just like</p>
  
  <pre><code>public static void main (String[] args) {
  
      matrix[][]=data[] ;
  
      for(int i=0,i&lt;5;i++){
  
          for(int j=0,j&lt;5;j++){
  
              System.out.print(matrix[i][j]);
  
          }
          System.out.println();
      }
  </code></pre>
  
  <p>the original class: </p>
  
  <pre><code>class permutation {
  
      static void combinationUtil(int arr[], int data[], int start, int end,int index, int r)
      {
          if (index == r)
          {
              for (int j=0; j&lt;r; j++)
              {
                  System.out.print(data[j]+" ");
              }
              System.out.println("");
              return;
          }
  
          for (int i=start; i&lt;=end &amp;&amp; end-i+1 &gt;= r-index; i++)
          {
              data[index] = arr[i];
              combinationUtil(arr, data, i+1, end, index+1, r);
          }
      }
  
      public static void main (String[] args) {
          int arr[] = {1, 2, 3, 4, 5};
          int r = 4;
          int n = arr.length;
          int data[]=new int[r];
          int start=0,end=n-1,index=0;
          combinationUtil(arr, data, start, end, index, r);
      }
  }
  </code></pre>