title: Search index of one Dimensional array in two dimensional array and return row by row java
body: <p>I've got a problem is that I have an array one dimensional </p>
  
  <pre><code>String[] purposeAll= {"P1","P2"};
  </code></pre>
  
  <p>and array two dimension </p>
  
  <pre><code>String[][] purpose = { 
          { "P1", "a", "b", "c", "d", "e", "f", "h" },
          { "P2", "a", "b", "c", "d", "e", "g", "i" },
          { "P3", "l", "m", "n", "o", "p", "q" } };
  </code></pre>
  
  <p>I need to search each index of array one dimension in array two dimension and result will get:</p>
  
  <pre><code>arrayOfPurpose[][]={ 
          { "P1", "a", "b", "c", "d", "e", "f", "h" },
          { "P2", "a", "b", "c", "d", "e", "g", "i" }  };
  </code></pre>
  
  <p>and my code is </p>
  
  <pre><code>public static void ArrayOfPurpose(String[][] purpose, String[] purposeAll) {
  
  String[][][] arrayOfPurpose = new String[purposeAll.length][purpose.length][];
      ArrayList&lt;String[]&gt; list = new ArrayList&lt;String[]&gt;();
  
      for (int i = 0; i &lt; purpose.length; i++) {
          list.add(purpose[i]);
      }
      String[] tmp;
      for (int k = 0; k &lt; purposeAll.length; k++) {
          arrayOfPurpose[k]= new String[purposeAll.length][];
          System.out.print("ok");
          for (int i = 0; i &lt; list.size(); i++) {
  
              tmp = list.get(i);
              arrayOfPurpose[i]= new String[purposeAll.length][tmp.length];
              for (int j = 0; j &lt; purpose[i].length; j++) {
                   if (tmp[0] == (purposeAll[k])) {
                      arrayOfPurpose[k][i][j] = tmp[j];
                    System.out.println(arrayOfPurpose[k][i][j]);
                  }
  
              }
  
          }
      }
  }
  </code></pre>
  
  <p>thank you very much !! :)</p>