public static void main(String[] args) {
List<Character> list = new ArrayList<Character>();
Set<String> hashSet = new HashSet<String>();
for (char i = 'a'; i <= 'z'; i++) {
list.add(i);
}
for (char i = 'A'; i <= 'Z'; i++) {
list.add(i);
}
for (char i = '0'; i <= '9'; i++) {
list.add(i);
}
while (hashSet.size() < 10) {
Set<Character> set = new HashSet<Character>();
while (set.size() < 10) {
Random random = new Random();
int index = random.nextInt(61);
Character c = list.get(index);
set.add(c);
}
String string = "";
for (char c : set) {
string = string + c;
}
System.out.println(string);
hashSet.add(string);
}
}
}
要求产生10个随机的字符串,每一个字符串互相不重复,每一个字符串中组成的字符(a-zA-Z0-9)也不相同,每个字符串长度为10
猜你喜欢
转载自blog.csdn.net/qq_41618510/article/details/83997790
今日推荐
周排行