java大陣列拆分多個小陣列
這幾天用到不少小東西,先放到部落格吧
import java.util.Random;
publicclass cdsc {
public String excute(int length)
{
StringBuffer buffer = new StringBuffer("0123456789abcdefghijklmnopqrstuvwxyz");
StringBuffer sb = new StringBuffer();
Random r = new Random();
int range = buffer.length();
for (int i = 0; i < length; i ++)
{
sb.append(buffer.charAt(r.nextInt(range)));
sb.append(",");
}
return sb.toString();
}
public static void main(String[] args) {
cdsc cds=new cdsc();
String a =cds.excute(111);
String[] b=a.split(",");
for (int j = 0; j < 100 ; j++) {
String[] s = new String[(int)Math.ceil(b.length/100.0)];
for (int i = 0; i < (int)Math.ceil(b.length/100.0); i++) {
if (i + j * (int)Math.ceil(b.length
return ;
}else{
s[i] = b[i + j * (int)Math.ceil(b.length/100.0)];
System.out.print(s[i] + ",");
}
} System.out.println();
}
}
}