Java Arrays fill方法-填充char


Java Arrays fill方法-填充char

package com.codingdict;

import java.util.Arrays;

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

      // initializing char array
      char arr[] = new char[] {'a','b','c'};

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

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

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