Here you can find the source of array2Dto1D(int[][] d2)
public static int[] array2Dto1D(int[][] d2)
//package com.java2s; /* ArrayUtil.java 1.0 2010-2-2 * // www . j a va 2 s. c o m * Copyright (c) 2010 by Chen Zhiwu * All rights reserved. * * The copyright of this software is own by the authors. * You may not use, copy or modify this software, except * in accordance with the license agreement you entered into * with the copyright holders. For details see accompanying license * terms. */ public class Main { public static int[] array2Dto1D(int[][] d2) { int hight = d2.length; int width = d2[0].length; int[] modImgArray = new int[width * hight]; for (int i = 0; i < hight; i++) { System.arraycopy(d2[i], 0, modImgArray, i * width, width); } return modImgArray; } public static void array2Dto1D(int[][] d2, int[] d1) { int hight = d2.length; int width = d2[0].length; for (int i = 0; i < hight; i++) { System.arraycopy(d2[i], 0, d1, i * width, width); } } }