Java Number Range Create range(String input[], int beginIndex, int endIndex)

Here you can find the source of range(String input[], int beginIndex, int endIndex)

Description

returns a range of a string table elements as a new string table

License

Open Source License

Parameter

Parameter Description
input string table
beginIndex first element of the range
endIndex last element of the range

Return

range

Declaration

public static String[] range(String input[], int beginIndex, int endIndex) 

Method Source Code

//package com.java2s;
/*/*from  w  w w  . ja  va  2 s  .c o m*/
 * IrssiBot - An advanced IRC automation ("bot")
 * Copyright (C) 2000 Matti Dahlbom
 * 
 * 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 (at your option) 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.
 *
 * mdahlbom@cc.hut.fi
 */

public class Main {
    /**
     * returns a range of a string table elements as a new string table
     * @param input string table
     * @param beginIndex first element of the range
     * @param endIndex last element of the range
     * @return range
     */
    public static String[] range(String input[], int beginIndex, int endIndex) {
        String ret[] = null;

        if (input != null) {
            if ((beginIndex >= 0) && (endIndex < input.length) && (beginIndex <= endIndex)) {
                ret = new String[endIndex - beginIndex + 1];

                for (int i = beginIndex; i <= endIndex; i++) {
                    ret[i - beginIndex] = input[i];
                }
            }
        }
        return ret;
    }

    /**
     * returns a range of a string table elements as a new string table
     * starting from beginIndex to end of the input table.
     * @param input string table
     * @param beginIndex first element of the range
     * @return range
     */
    public static String[] range(String input[], int beginIndex) {
        return range(input, beginIndex, input.length - 1);
    }
}

Related

  1. range(int value, int min, int max)
  2. range(Integer from, Integer to)
  3. range(long array[])
  4. range(long start, long end)
  5. range(String field, int start, int end)
  6. range(String second, String first)
  7. range(T val, T min, T max)
  8. RangeConvert(float start, float end, float newStart, float newEnd, float value)