Java tutorial
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 18 from index 2 to 4 Arrays.fill(arr, 2, 4, 18); System.out.println(Arrays.toString(arr)); } }