bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths

Loading lesson path

Learn/Java/Java Reference
Java•Java Reference

Java Arrays. fill() Method

❮ Arrays Methods

String[] fruits = {"Banana", "Orange", "Apple", "Mango"};
Arrays.fill(fruits, "Kiwi");

Definition and Usage

The fill() method fills an array with a specified value.

Note

The value must be of the same data type as the array.

Tip

Start and end position can be specified. If not, all elements will be filled.

Syntax

Arrays.fill( array , value )
Arrays.fill( array , start , end , value )

Parameter Values

ParameterDescription
arrayRequired. The array to be filled
startOptional. The index position of the first element (inclusive) to be filled
endOptional. The index position of the last element (exclusive) to be filled
valueRequired. The value to fill in the array

Technical Details

Returns:No return value
Java version:1.2 ( java.util )

Previous

Java Arrays. sort() Method

Next

Java Array length Property