// " 第三题:分析以下需求,并用代码实现
// " 1.产生10个1-20之间的随机数要求随机数不能重复
// " 2.产生10个长度为10的不能重复的字符串(里面只能出现大写字母、小写字母、0-9的数字),并遍历打印输出
public class Prctice03 {
public static void main(String[] args) {
Random r = new Random();
HashSet<Integer> hs = new HashSet();
while (hs.size() < 10) {
int Num = r.nextInt(20) + 1;
hs.add(Num);
}
System.out.println(hs);
System.out.println("=========================================================================");
ArrayList<Character> list = new ArrayList<>();
for (int i = '0'; i <= '9'; i++) {
char a = (char) (i);
list.add(a);
}
for (int i = 'a'; i <= 'z'; i++) {
char a = (char) (i);
list.add(a);
}
for (int i = 'A'; i <= 'Z'; i++) {
char a = (char) (i);
list.add(a);
}
for (int i = 0; i < 10; i++) {
// " 第三题:分析以下需求,并用代码实现
// " 1.产生10个1-20之间的随机数要求随机数不能重复
// " 2.产生10个长度为10的不能重复的字符串(里面只能出现大写字母、小写字母、0-9的数字),并遍历打印输出
public class Prctice03 {
public static void main(String[] args) {
Random r = new Random();
HashSet<Integer> hs = new HashSet();
while (hs.size() < 10) {
int Num = r.nextInt(20) + 1;
hs.add(Num);
}
System.out.println(hs);
System.out.println("=========================================================================");
ArrayList<Character> list = new ArrayList<>();
for (int i = '0'; i <= '9'; i++) {
char a = (char) (i);
list.add(a);
}
for (int i = 'a'; i <= 'z'; i++) {
char a = (char) (i);
list.add(a);
}
for (int i = 'A'; i <= 'Z'; i++) {
char a = (char) (i);
list.add(a);
}
for (int i = 0; i < 10; i++) {