今日总结
处理了数据结构作业
import java.util.Random;
public class RandomStr {
public static String generateRandomCode() {
Random random = new Random();
StringBuilder code = new StringBuilder();
for (int i = 0; i < 6; i++) {
int randomNumber = random.nextInt(10);
code.append(randomNumber);
}
return code.toString();
}
public static void main(String[] args) {
String randomCode = generateRandomCode();
System.out.println("生成的验证码为:" + randomCode);
}
}