Fill elements in a Java int array in a specified range

import java.util.Arrays;
public class Demo {
   public static void main(String[] argv) throws Exception {
      int[] intArray = new int[10];
		int intValue = 7;
		int indexStart = 2;
		int indexFinish = 8;
		Arrays.fill(intArray, indexStart, indexFinish, intValue);
		System.out.println("The int array content is: " + Arrays.toString(intArray));


We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.