Java Array Slice slice(T[] array, int index)

Here you can find the source of slice(T[] array, int index)

Description

slice

License

Open Source License

Declaration

public static <T> List<T[]> slice(T[] array, int index) 

Method Source Code

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

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Main {
    public static <T> List<T[]> slice(T[] array, int index) {
        List<T[]> arrayList = new ArrayList<T[]>();
        T[] slice1 = Arrays.copyOfRange(array, 0, index);
        T[] slice2 = Arrays.copyOfRange(array, index, array.length);
        arrayList.add(slice1);//from  ww  w. j  av  a  2 s .  c om
        arrayList.add(slice2);
        return arrayList;
    }
}

Related

  1. slice(String[] array, int a, int b)
  2. slice(String[] array, int index, int length)
  3. slice(String[] o, int index)
  4. slice(String[] strings, int begin, int length)
  5. slice(String[] strings, int begin, int length)
  6. slice(T[] array, int index, int length)
  7. slice(T[] array, int start, int finish)
  8. slice(T[] items, int offset, int length)
  9. sliceArray(final String[] array, final int start)