在子数组上划分给定数组
/** from * N o w J a v a . c o m **/ //package com.nowjava; import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class Main { /** * Divides given array on sub arrays * * @param arr * the original array that be divided on sub arrays * @param subArrSize * the size of each sub array * @return the java.util.List<Integer[]> of sub arrays */ public static List<Integer[]> getSubarraysList(Integer[] arr, int subArrSize) { int arrLength = arr.length; List<Integer[]> arrList = new ArrayList<Integer[]>(); int subarraysCount = (int) Math.ceil((double) arrLength / subArrSize); for (int i = 0; i < subarraysCount; i++) { if (i == subarraysCount - 1) { Integer[] curArr = Arrays.copyOfRange(arr, i * subArrSize, arrLength); arrList.add(curArr); } else { /* *来 自 时 代 J a v a