Java Arrays copyOf 方法拷贝Short类型


Java Arrays copyOf 方法拷贝Short类型

package com.codingdict;

import java.util.Arrays;

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

      // initializing unsorted short array
      Short shortArr[] = new Short[]{5, 2, 15, 52, 10};

      // copy the array into another Number array
      Number[] arr2 = Arrays.copyOf(shortArr, 5, Number[].class);

      // let us print all the elements available in list
      System.out.println("The copied number array is:");
      for (Number number : arr2) {
         System.out.println("Number = " + number);
      }
   }
}