title: How can you convert a 2 dimensional array into a 1 dimensional array in Java
body: <p>I would like to know how to convert a 2 dimensional array into a 1 dimensional array. I have come up with some code but it doesn't exactly seem to work. Can someone please help me? Thanks.</p>
  
  <pre><code>public class TESTER1 {
  
      /**
       * @param args
       */
  
      static String[][] data = new String[][] {{"Dum","Dumer","Dumbest"}};
  
      public static void main(String[] args) {
  
          convertData(data);
      }
  
      public static void convertData(String[][]data) {
          String[] toReturn = new String[data.length];
          for(int i = 0;i&lt;data.length;i++) {
              for(int j = 0;j&lt;3;j++){
                  toReturn[i] = data[i][j];
              }
          }
          for(String s:toReturn) {
              System.out.println(s);
          }
      }
  }
  </code></pre>
  
  <p>[edit]Thank you very much. Is it possible to convert each row in the String[][] into
  a index in a String[] for example if we convert the String[][] (above code), then when
  i print out array[0] it should print out dum,dummer,dumbest [edit]</p>