Here you can find the source of arrayCopyToNull(T[] source, int sourceOffset, T[] destination, int destinationOffset)
Parameter | Description |
---|---|
T | the object type stored in the arrays. |
source | the source array. |
sourceOffset | the source offset. |
destination | the destination array. |
destinationOffset | the starting destination offset. |
Parameter | Description |
---|---|
ArrayIndexOutOfBoundsException | if this tries to resolve a destination that is out of bounds. |
public static <T> int arrayCopyToNull(T[] source, int sourceOffset, T[] destination, int destinationOffset)
//package com.java2s; /******************************************************************************* * Copyright (c) 2009-2016 Black Rook Software * All rights reserved. This program and the accompanying materials * are made available under the terms of the GNU Lesser Public License v2.1 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html ******************************************************************************/ public class Main { /**//from www. ja va 2s . c om * Copies references from one array to another until * it hits a null sentinel reference or the end of the source array. * @param <T> the object type stored in the arrays. * @param source the source array. * @param sourceOffset the source offset. * @param destination the destination array. * @param destinationOffset the starting destination offset. * @return how many references were copied. * @throws ArrayIndexOutOfBoundsException if this tries to resolve a destination that is out of bounds. * @since 2.21.0 */ public static <T> int arrayCopyToNull(T[] source, int sourceOffset, T[] destination, int destinationOffset) { int s; for (s = 0; s + sourceOffset < source.length && source[s + sourceOffset] != null; s++) destination[s + destinationOffset] = source[s + sourceOffset]; return s; } }