Java Array Fill fill( T[] a, T val)

Here you can find the source of fill( T[] a, T val)

Description

Assigns the specified T reference val to each element of the array a.

License

Open Source License

Parameter

Parameter Description
a the array to be filled.
val the value to be stored in all elements of the array.

Return

a

Declaration

public static <T> T[] fill( T[] a, T val) 

Method Source Code

//package com.java2s;

import java.util.Arrays;

public class Main {
    /**//  w w  w  . j  a va2  s  . c o  m
     * Assigns the specified T reference <code>val</code> to each element of the
     * array <code>a</code>.
     *
     * @param a the array to be filled.
     * @param val the value to be stored in all elements of the array.
     * @return a
     */
    public static <T> T[] fill(/*INOUT*/ T[] a, T val) {
        Arrays.fill(a, val);
        return a;
    }
}

Related

  1. fill(byte[] arr)
  2. fill(byte[] val, byte b)
  3. fill(char[] chars, int fromIndex, int toIndex, char c)
  4. fill(double[][] array, double s)