According to the following example, the number of 1 1 is transmitted for the first time, then three arrays are printed, and then four arrays can be printed, and the number is 12, which is expected to be adopted.
Packaging test;
Import java.util.arrays;
Public class splitArr {
public static int[][]split(int[]arr,int n){
int m = arr.length/n; //Number of arrays returned
int[][]result = new int[m][n];
If (array length ==0||n==0){
Return the result;
} Otherwise {
for(int I = 0; I & ltm;; i++){
for(int j = 0; j & ltn; j++){
result[I][j]= arr[n * I+j];
}
}
}
Return the result;
}
Public static void main(String [] args){
int[] arr = new int []{ 1,2,3,4,5,6,7,8,9, 10, 1 1 };
int n = 3;
int[][]result = split arr . split(arr,n);
for(int I = 0; I < Result. Length; i++){
system . out . println(arrays . tostring(result[I]));
}
}
}
verify the result