Here you can find the source of subArray(final char[] source, int from, int to)
Parameter | Description |
---|---|
source | a parameter |
from | inclusive |
to | inclusive |
public static char[] subArray(final char[] source, int from, int to)
//package com.java2s; //License from project: Apache License public class Main { /**// ww w .j ava 2s . c o m * Best for arrays less than 20 cells * @param source * @param from inclusive * @param to inclusive * @return */ public static char[] subArray(final char[] source, int from, int to) { char[] target = new char[to - from + 1]; for (int i = 0; i < target.length; i++) { target[i] = source[from + i]; } return target; } /** * Best for arrays less than 20 cells. * @param source * @param length * @return sub-array from 0 of desire length */ public static char[] subArray(final char[] source, int length) { return subArray(source, 0, length - 1); } }