67,515
社区成员
发帖
与我相关
我的任务
分享
public static void main(String[] args) {
int count = 1;
Set<Character> set = new HashSet<>(4);
while (count < 5) {
// ASCII B对应的十进制值
int Min = 66;
// ASCII K对应的十进制值
int Max = 75;
// B-K范围内,包含B/K值
int result = Min + (int)(Math.random() * ((Max - Min) + 1));
if (set.add((char)result)) {
count ++;
}
}
System.out.println(set);
}
不知道是不是你想要的