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


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

package com.codingdict;

import java.util.Arrays;

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

      // initializing float array
      float arr[] = new float[] {1f, 5f, 3f, 2f, 9f};

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

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

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