Arrays.fill(int[] a, int val) has the following syntax.
public static void fill(int[] a, int val)
In the following code shows how to use Arrays.fill(int[] a, int val) method.
//from w w w . j ava2 s . co m import java.util.Arrays; public class Main { public static void main(String[] args) { // initializing int array int arr[] = new int[] {1, 2, 3, 4, 5}; System.out.println(Arrays.toString(arr)); // using fill for placing 8 Arrays.fill(arr, 8); System.out.println(Arrays.toString(arr)); } }
The code above generates the following result.