该程序将生成100个随机4个字母的数字,它首先生成4个字母,然后生成4个字母并将它们添加到函数中。我猜是因为我使用了.append。我试着把随机=“”;在循环的顶部和底部,但它只是清除了变量。有没有其他办法可以做到这一点,或者有什么我可以添加到该程序?如何清除循环中的变量
Random input = new Random();
StringBuilder in = new StringBuilder();
String alphabet = "abcdefghijklomnpqrstuvwxyz";
char[] letterPool;
letterPool = alphabet.toCharArray();
for(int y = 0; y < 101; y++){
for(int x = 0; x<4; x++){
in.append(alphabet.charAt(input.nextInt(alphabet.length())));
}
String random=in.toString();
System.out.println(random);
System.out.println("space");
}
呵呵?? <垫垫垫> – John3136