Java Arrays copyOfRange方法针对boolean类型


Java Arrays copyOfRange方法针对boolean类型

package com.codingdict;

import java.util.Arrays;

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

      // intializing an array arr1
      boolean[] arr1 = new boolean[] {true, false, false};

      // printing the array arr1
      System.out.println("Printing 1st array:");
      for (int i = 0; i < arr1.length; i++) {
         System.out.println(arr1[i]);  
      }

      // copying array arr1 to arr2 with range from index 1 to 4
      boolean[] arr2 = Arrays.copyOfRange(arr1, 1, 4);

      // printing the array arr2
      System.out.println("Printing new array:");
      for (int i = 0; i < arr2.length; i++) {
         System.out.println(arr2[i]);
      }
   }
}