Java Arrays Fill
By using the Arrays.fill() method, we can either fill a complete array or can fill some part of it. Arrays.fill() method is also capable of filling both the 2D and the 3D Arrays.
Arrays fill() method has the following syntax:
Let's take some examples to understand how we can use the Arrays.fill() method for filling array.
Fill entire 1-D Array
Fill some part of 1-D Array
Fill multidimensional array (2D Array)
Just like a single-dimensional array, we can also fill the multidimensional array by using the Arrays.fill() method. In order to fill a multidimensional array, we use the for loop to fill each row of the multidimensional array.
Let's take an example to understand how we can fill a multidimensional array using the Arrays.fill() method.