One, array
declaration of the array:
Mode one: String [] str1=new string[10];
Mode two: String [] str2={"A", "V"};
1. Divide a large array into n decimal groups
Public Static<T> list<object[]> ARRAYSPL (T [] str,intnum) { if(str==NULL|| Str.length==0){ Throw NewNullPointerException ("Array cannot be empty"); } if(num==0){ Throw NewNumberFormatException ("Can't be 0"); } intStrlength=str.length;//the length of the array intLen= (strlength%num==0) strlength/num:strlength/num+1;//number of new arrayslist<object[]>listarray=NewArraylist<object[]>(); if(num>=strlength) {Listarray.add (str); }Else{Object [] arr2=NULL; for(inti=0;i<len;i++){ intM=0; ARR2=NewObject[num]; if(strlength%num!=0){ if(i+1==Len) {ARR2=Newobject[strlength-(i*num)]; } } for(intj=i*num;j<strlength;j++) {m++; Arr2[m-1]=Str[j]; if(m==num) {m=0; Break; }} listarray.add (ARR2); } }
View Code
Common Java Methods