Here you can find the source of subarray(final String[] arr, int first, final int last)
Parameter | Description |
---|---|
arr | The array. |
first | First element to keep (new 0-index). |
last | Last element to keep. |
public static String[] subarray(final String[] arr, int first, final int last)
//package com.java2s; /*/* ww w.j a v a 2s . co m*/ * 20:25:20 20/05/99 * * The Java Shell: Utilities. * (C)1999 Romain Guy, Osvaldo Pinali Doederlein. * * LICENSE * ======= * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * CHANGES * ======= * 1.0.8 - Filled the listRoots method (Romain & Osvaldo) * 1.0.7 - Several bug fixes in constructPath (Romain) * 1.0.6 - Split JDK1.1/1.2 (Osvaldo) * 1.0.5 - Important bug fix in constructPath(String) (Romain) * 1.0.4 - Added getSize(Enumeration) (Osvaldo) * 1.0.3 - Changed sortStrings bubble-sort algorithm to (Romain) * quick-sort (James Gosling) * 1.0.2 - Fixed two little bug in constructPath(String) (Romain) * 1.0.1 - Added listFiles(String[], boolean) (Romain) * - Removed unecessary createWhiteSpace(int) (Romain) * - Modified getWildCardMatches(String, boolean) (Romain) * - Slighty improved javadoc comments (Romain) * 1.0.0 - Initial release. (Romain & Osvaldo) * * LINKS * ===== * Contact: mailto@osvaldo.visionnaire.com.br * Site #1: http://www.geocities.com/ResearchTriangle/Node/2005/ * Site #2: http://student.vub.ac.be/~opinalid/ */ public class Main { /** * Removes some elements from a String array. * * @param arr * The array. * @param first * First element to keep (new 0-index). * @param last * Last element to keep. * @return Copy of arr[first..] */ public static String[] subarray(final String[] arr, int first, final int last) { final String[] newArr = new String[last - first + 1]; for (int i = 0; i < newArr.length; ++i, ++first) { newArr[i] = arr[first]; } return newArr; } /** * Removes some leading elements from a String array. * * @param arr * The array. * @param first * First element to keep (new 0-index). * @return Copy of arr[first..] */ public static String[] subarray(final String[] arr, final int first) { return subarray(arr, first, arr.length - 1); } }