The java.util.Arrays.fill(int[] a, int val) method assigns the specified int value to each element of the specified array of ints.
Syntax:public static void fill(int[] a, int val)
Example:import java.util.Arrays;
public class ArrayDemo {
public static void main(String[] args) {
// initializing int array
int arr[] = new int[] {1, 6, 3, 2, 9};
// let us print the values
System.out.println("Actual values: ");
for (int value : arr) {
System.out.println("Value = " + value);
}
// using fill for placing 18
Arrays.fill(arr, 18);
// let us print the values
System.out.println("New values after using fill() method: ");
for (int value : arr) {
System.out.println("Value = " + value);
}
}
}
License.
All information of this service is derived from the free sources and is provided solely in the form of quotations.
This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 382 / 158778396. Delta: 0.05212 с