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, 2, 9};

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

      // using fill for placing 64 from index 2 to 4
      // converting int to byte
      Arrays.fill(arr, 2, 4, (byte)64);

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