Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/**
 * Helpful methods for collections.
 * 
 * ## Legal stuff
 * 
 * Copyright 2014-2014 Ekkart Kleinod <ekleinod@edgesoft.de>
 * 
 * This file is part of edgeUtils.
 * 
 * edgeUtils is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * edgeUtils 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 Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with edgeUtils.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * @author Ekkart Kleinod
 * @version 0.2
 * @since 0.2
 */

import java.util.ArrayList;

import java.util.Collections;
import java.util.List;

public class Main {
    /**
     * Returns a list of the given size containing value.
     * 
     * @param theValue value to be filled with
     * @param theSize size of the collection
     * @return list containing value
     * 
     * @version 0.2
     * @since 0.2
     */
    public static <T> List<T> getFilledList(T theValue, int theSize) {
        if (theSize < 0) {
            return Collections.emptyList();
        }

        List<T> lstReturn = new ArrayList<>();
        for (int i = 0; i < theSize; i++) {
            lstReturn.add(theValue);
        }

        return lstReturn;
    }
}