Java Arrays fill方法-使用索引填充boolean


Java Arrays fill方法-使用索引填充boolean

package com.codingdict;

import java.util.Arrays;

public class ArrayDemo {
   public static void main(String[] args) {

      // initializing boolean array
      boolean arr[] = new boolean[] {true, true, true, true, true};

      // let us print the values
      System.out.println("Actual values: ");
      for (boolean value : arr) {
         System.out.println("Value = " + value);
      }

      // using fill for placing false from index 1 to 4
      Arrays.fill(arr, 1, 4, false);

      // let us print the values
      System.out.println("New values after using fill() method: ");
      for (boolean value : arr) {
         System.out.println("Value = " + value);
      }
   }
}