Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.List;

public class Main {
    public static <T> void slice(List<T> oldList, List<T> newList, int start, int len) {
        newList.clear();
        int end = start + len;
        for (int i = start; i < end; i++) {
            newList.add(oldList.get(i));
        }
    }

    public static byte[] slice(byte[] array, int start, int len) {
        byte[] r = new byte[len];
        System.arraycopy(array, start, r, 0, len);
        return r;
    }

    public static int[] slice(int[] array, int start, int len) {
        int[] r = new int[len];
        System.arraycopy(array, start, r, 0, len);
        return r;
    }

    public static String[] slice(String[] array, int start, int len) {
        String[] r = new String[len];
        for (int i = 0; i < len; i++) {
            r[i] = array[i + start];
        }
        return r;
    }
}