簡單,我只是想要一個代碼(而不是在控制檯中打印出各行文本)只更新一行文本和新值,或者「替換」它。如何更新一行而不是多行?
目前代碼:
//this code was expanded into a more configurable version
//original author is zengr
public final class EnumRandValue {
public static final void main(String... aArgs){
int min = 12;
int max = 157;
int ints = 1000;
//how many numbers to generate?
int enumeration = 1;
int maximumints = 1000;
//advanced users only!
log("Generating " + ints + " random integers in range of " + (min-1) + " and " + (max-1) + ".");
//note a single Random object is reused here
if(min < max || min != max) {
Random randomGenerator = new Random();
for (int idx = 1; idx <= ints; ++idx){
int randomInt = randomGenerator.nextInt(max);
log("E" + enumeration++ + ": " + randomInt);
if(enumeration >= maximumints) {
String breakmsg = "Exceeded enums limit (" + maximumints + ").";
log(breakmsg);
return;
} else if(min >= max) {
String breakmsg = "Invalid min/max values.";
log(breakmsg);
return;
} else {
//really nothing happens here
//some code was excluded
這裏有什麼期望?和你分享的代碼是什麼/ – nullpointer
什麼是'log()'? –
它只是使用最小值和最大值生成一個隨機數列表。它的輸出如下所示: '生成10箇中的11範圍和隨機整數156. E1:50 E2:15 E3:115 E4:142 E5:133 E6:55 E7:59 E8 :138 E9:134 E10:45' – Icy4614