Java Arrays fill方法-填充Object


Java Arrays fill方法-填充Object

package com.codingdict;

import java.util.Arrays;

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

      // initializing Object array
      Object arr[] = new Object[] {10.5, 5.6, 4.7, 2.9, 9.7};

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

      // using fill for placing 12.2
      Arrays.fill(arr, 12.2);

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