java编程 这道题Random类做 有人帮忙吗?Random类编写谢谢
展开全部
import java.util.Random;
public class Main {
private static final Random RND = new Random();
public static int randint(int max) {
return RND.nextInt(max);
}
public static String genPlateNumber() {
StringBuilder sb = new StringBuilder(7);
for (int i=0; i<3; i++) {
char ch = (char) (randint(26) + 'A');
sb.append(ch);
}
for (int i=0; i<4; i++) {
sb.append(randint(10));
}
return sb.toString();
}
public static void main(String[] args) {
for (int i=0; i<10; i++) {
System.out.println(genPlateNumber());
}
}
}
追问
谢谢大哥
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询