配列に対して指定された個数のセットで【アルゴリズム】demoを出力する


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,