Java Array Two Dimension to One Dimension array2DTo1D(int[][] array2D)

Here you can find the source of array2DTo1D(int[][] array2D)

Description

array D To D

License

Creative Commons License

Declaration

public static int[] array2DTo1D(int[][] array2D) 

Method Source Code

//package com.java2s;
/*/*from   w ww.  j a va2 s.  c o m*/
 * Universidad Nacional de Colombia - Sede Bogot? *
 *
 *      Christian Rodriguez - carodriguezb@unal.edu.co
 *
 * C?digo liberado bajo licencia Creative Commons 3.0
 * http://creativecommons.org/licenses/by-nc-sa/3.0/
*/

public class Main {
    public static int[] array2DTo1D(int[][] array2D) {
        int[] array1D = new int[array2D[0].length * array2D.length];
        for (int x = 0; x < array2D.length; x++) {
            for (int y = 0; y < array2D[0].length; y++) {
                array1D[(x * array2D.length) + y] = array2D[x][y];
            }
        }
        return array1D;
    }
}

Related

  1. array2dcopy(final String[][] src, final String[][] target)
  2. array2dCopy(Object[][] src, Object[][] dest)
  3. array2DTo1D(double[][] In)
  4. array2dTo1d(float[][] in)
  5. array2Dto1D(int m, int n, double[][] a)
  6. array2Dto1D(int[][] d2)
  7. array2Square(short[] ar, int rows, int cols)