Here you can find the source of flatten(E[][] a)
Parameter | Description |
---|---|
a | a parameter |
E | a parameter |
public static <E> ArrayList<E> flatten(E[][] a)
//package com.java2s; /******************************************************************************* * OscaR is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 2.1 of the License, or * (at your option) any later version./*from ww w. j av a 2 s. c om*/ * * OscaR 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License along with OscaR. * If not, see http://www.gnu.org/licenses/lgpl-3.0.en.html ******************************************************************************/ import java.util.ArrayList; public class Main { /** * * @param a * @param <E> * @return a flattened array list of all elements in a */ public static <E> ArrayList<E> flatten(E[][] a) { ArrayList<E> res = new ArrayList<E>(); for (int i = 0; i < a.length; i++) { for (int j = 0; j < a[i].length; j++) { res.add(a[i][j]); } } return res; } }