Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import java.util.Arrays;

public class Main {
    /**
     * Concatenates a list of float arrays into a single array.
     * 
     * @param arrays The arrays.
     * @return The concatenated array.
     * 
     * @see {@link http://stackoverflow.com/questions/80476/how-to-concatenate-two-arrays-in-java}
     */
    public static float[] concatAllFloat(float[]... arrays) {
        int totalLength = 0;
        final int subArrayCount = arrays.length;
        for (int i = 0; i < subArrayCount; ++i) {
            totalLength += arrays[i].length;
        }
        float[] result = Arrays.copyOf(arrays[0], totalLength);
        int offset = arrays[0].length;
        for (int i = 1; i < subArrayCount; ++i) {
            System.arraycopy(arrays[i], 0, result, offset, arrays[i].length);
            offset += arrays[i].length;
        }
        return result;
    }
}