Table of Content

Fill an Object Array in Java


Declaration :

Explanation :

Purpose The java.util.Arrays.fill(Object[] a Object val) method assigns the specified Object reference to each element of the specified array of Objects.
Parameters a ===> This is the array to be filled.
val ===> This is the value to be stored in all elements of the array.
Return Value This method does not return value.
Exception ArrayStoreException — if the specified value is not of a runtime type that can be stored in the specified array.

Java Program : Example

Below example will explain java.util.Arrays.fill() method.

Output of Program :