Here you can find the source of flatten(double[][] spills)
public static double[] flatten(double[][] spills)
//package com.java2s; /*/*from w w w . j a v a2s . c om*/ * ------------------------------------------------------------------------ Copyright 2016 by Aaron * Hart Email: Aaron.Hart@gmail.com * * This program is free software; you can redistribute it and/or modify it under the terms of the * GNU General Public License, Version 3, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along with this program; if * not, see <http://www.gnu.org/licenses>. * --------------------------------------------------------------------- * * Created on December 14, 2016 by Aaron Hart */ public class Main { public static double[] flatten(double[][] spills) { double[] flat; if (spills.length > 0) { flat = new double[spills.length * spills[0].length]; for (int i = 0; i < spills.length; i++) { for (int j = 0; j < spills[0].length; j++) { flat[i * spills[0].length + j] = spills[i][j]; } } } else { flat = new double[] {}; } return flat; } }