Java Array Slice slice(String[] array, int a, int b)

Here you can find the source of slice(String[] array, int a, int b)

Description

slice

License

Apache License

Declaration

public static String[] slice(String[] array, int a, int b) throws Exception 

Method Source Code

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

public class Main {
    public static String[] slice(String[] array, int a, int b) throws Exception {
        String[] newarray = new String[b - a];
        if (!(a < array.length && b <= array.length)) {
            throw new Exception("out of bound:" + a + "," + b);
        }/*w  w w .ja  v  a  2s . c o m*/
        for (int i = a; i < b; i++) {
            newarray[i - a] = array[i];
        }

        return newarray;
    }
}

Related

  1. arraySlice(Object[] source, Object[] dest, int startIdx)
  2. slice(byte[] buffer, int start, int end)
  3. slice(byte[] source, int start, int end)
  4. slice(Object[] objects, int begin, int length)
  5. slice(String source[], int start, int end)
  6. slice(String[] array, int index, int length)
  7. slice(String[] o, int index)
  8. slice(String[] strings, int begin, int length)
  9. slice(String[] strings, int begin, int length)