Here you can find the source of subArray(String[] data, int index, int length)
Parameter | Description |
---|---|
data | The original array. |
index | The start index. |
length | The length that should get copied. |
public static String[] subArray(String[] data, int index, int length)
//package com.java2s; /*/*w ww . j a v a 2 s. c o m*/ * Copyright 2012 BMW Car IT GmbH * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ public class Main { /** * Returns a subarray of the given array. * * @param data * The original array. * @param index * The start index. * @param length * The length that should get copied. * @return The subarray. */ public static String[] subArray(String[] data, int index, int length) { if (index + length > data.length) { throw new IllegalArgumentException("invalid length of input array"); } String[] result = new String[length]; System.arraycopy(data, index, result, 0, length); return result; } }