java数组拆分_将一个数组按照固定大小进行拆分成数组的方法

  • Post author:
  • Post category:java


如下所示:

/**

* ArraySplit.java

* Copyright(C) 2014

*/

package com.udpdemo.test2;

import java.util.ArrayList;

import java.util.List;

/**

*

* @author cuiran

* @version 1.0.0

*/

public class ArraySplit {

/**

* @param args

*

*/

public static void main(String[] args) {

// TODO Auto-generated method stub

int[] ary = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};//要分割的数组

int splitSize = 5;//分割的块大小

Object[] subAry = splitAry(ary, splitSize);//分割后的子块数组

for(Object obj: subAry){//打印输出结果

int[] aryItem = (int[]) obj;

for(int i = 0; i < aryItem.length; i++){

System.out.print(aryItem[i] + “, “);

}

System.out.println();



版权声明:本文为weixin_30995661原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。