Java Arrays fill方法-填充byte


Java Arrays fill方法-填充byte

package com.codingdict;

import java.util.Arrays;

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

      // initializing byte array
      byte arr[] = new byte[] {1, 6, 3};

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

      // using fill for placing 8
      // converting int to byte
      Arrays.fill(arr,(byte)8);

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