package test;
public class Test {
public static void main(String[] args) {
// TODO Auto-generated method stub
int a[]={1,2,3,4,5,6,7,8};
int length=a.length;
int num=5; //一次性输出的个数;
int j=0;
while(j<=length/num){
for(int i=num*j;i<num*(j+1);i++){
if(i<length){
System.out.print(a[i]+",");
}
}
j++;
System.out.println();
}
}
}
//运行结果:1,2,3,4,5,
// 6,7,8,
转载于:https://my.oschina.net/haopeng/blog/87197