Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import java.lang.reflect.Array;

public class Main {
    public static <M extends Object> M[] subArray(M[] array, int start, int end) {
        end = Math.min(array.length, end);
        if (start >= end)
            return null;

        M[] result = (M[]) Array.newInstance(array[0].getClass(), end - start);
        System.arraycopy(array, start, result, 0, result.length);

        return result;
    }
}