int count = 10000;
long start = System.currentTimeMillis();
for (int i = 0; i < count; i++) {
String code = (Math.random() + "").substring(2, 8);
if (code.length() != 6) {
System.out.println("生成失败:" + code);
}
}
long end = System.currentTimeMillis();
System.out.println("截取耗时:" + (end - start));
System.out.println("===================================================");
start = System.currentTimeMillis();
for (int i = 0; i < count; i++) {
String code = String.valueOf((int) ((Math.random() * 9 + 1) * Math.pow(10, 5)));
if (code.length() != 6) {
System.out.println("生成失败:" + code);
}
}
end = System.currentTimeMillis();
System.out.println("整数运算,执行时间:" + (end - start));
耗时: