Set all elements of a to the value v; return a. - Java Collection Framework

Java examples for Collection Framework:Set

Description

Set all elements of a to the value v; return a.

Demo Code


//package com.java2s;

public class Main {
    /**//from  w  w  w  .j a  v a  2s.c o m
     * Set all elements of a to the value v; return a.
     */
    public static <T> T[] fill(final T[] array, final T value) {
        for (int i = 0; i < array.length; i++) {
            array[i] = value;
        }
        return array;
    }
}

Related Tutorials