Here you can find the source of fillNull(final List
public static <E> void fillNull(final List<E> list, final int numElements)
//package com.java2s; /******************************************************************************* * Copyright (c) 2015, 2017 Lablicate GmbH. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors:/*from www. java 2 s .c o m*/ * Dr. Alexander Kerner - initial API and implementation *******************************************************************************/ import java.util.List; public class Main { public static <E> void fillNull(final List<E> list, final int numElements) { if (numElements < list.size()) return; final int iterations = numElements - list.size(); for (int i = 0; i < iterations; i++) { list.add(null); } } }