Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.lang.reflect.Array;

public class Main {
    public static <T> T[] convertToSingleArray(T[][] a_arrayOfArrays, Class<T[]> a_destType)
    /*     */ {
        /* 230 */int iTotalLength = 0;
        /* 231 */for (Object[] srcArray : a_arrayOfArrays)
        /*     */ {
            /* 233 */if (srcArray == null)
                /*     */continue;
            /* 235 */iTotalLength += srcArray.length;
            /*     */}
        /*     */
        /* 242 */Object[] dest = (Object[]) (Object[]) Array.newInstance(a_destType.getComponentType(),
                iTotalLength);
        /*     */
        /* 245 */int iDestPointer = 0;
        /* 246 */for (Object[] srcArray : a_arrayOfArrays)
        /*     */ {
            /* 248 */if (srcArray == null)
                /*     */continue;
            /* 250 */System.arraycopy(srcArray, 0, dest, iDestPointer, srcArray.length);
            /* 251 */iDestPointer += srcArray.length;
            /*     */}
        /*     */
        /* 255 */return (T[]) dest;
        /*     */}
}