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


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

package com.codingdict;

import java.util.Arrays;

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

      // initializing double array
      double arr[] = new double[] {1.2, 5.6, 3.4, 2.9, 9.7};

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

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

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