bugl
bugl
HomeLearnPatternsPathsSearch
HomeLearnPatternsPathsSearch

Loading lesson path

Learn/Java/Java Reference
Java•Java Reference

Java Arrays. fill() Method

Flash cards

Review the key moves

1/4
Core idea

What is the main idea behind Java Arrays. fill() Method?

Lesson checks

Practice each idea before moving on

Short Mimo-style checks built from this lesson's code, terms, and sequence.

1Quick choice

Which statement best captures the main point of this lesson?

2Fill blank

Complete the missing token from the example code.

___[] fruits = {"Banana", "Orange", "Apple", "Mango"};
3Order

Put the learning moves in the order that makes the concept easiest to apply.

The fill() method fills an array with a specified value.
Definition and Usage
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