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 int[] remove(int[] array, int start, int len) {
        int[] r = new int[array.length - len];
        System.arraycopy(array, 0, r, 0, start);
        System.arraycopy(array, start + len, r, start, array.length - start - len);
        return r;
    }

    @SuppressWarnings("unchecked")
    public static <T> T[] remove(T[] array, int start, int len, Class<T> clazz) {
        T[] r = (T[]) Array.newInstance(clazz, array.length - len);
        System.arraycopy(array, 0, r, 0, start);
        System.arraycopy(array, start + len, r, start, array.length - start - len);
        return r;
    }
}