Home >Java >javaTutorial >How to fill arrays.fill in java
1. Concept
Array elements can be filled with the same value.
2. Syntax
public static void fill(int[] a, form, to, int var)
3. Parameters
a: Array
form: Replacement start Position (inclusive)
to: replacement end position (exclusive)
var: value to be replaced
4. Example
String[] a9 = new String[6]; Arrays.fill(a9, "Hello"); Arrays.fill(a9, 3, 5,"World");
The result is
a9[] = {Hello,Hello,Hello,World,World,Hello};
The first parameter refers to the array of operation, the second and third parameters refer to inserting the fourth parameter in a certain area of the array, the second parameter refers to the starting element The subscript (including the subscript), the third parameter refers to the end subscript (excluding the subscript), note: Java's array subscript starts from 0.
The above is the detailed content of How to fill arrays.fill in java. For more information, please follow other related articles on the PHP Chinese website!