第1个回答 2016-04-06
package com.wxy;
import java.util.HashSet;
import java.util.Random;
import java.util.Set;
public class Random7
{
public static void main(String[] args)
{
int arr[] = new int[10];
Random rand =new Random();
HashSet<Integer> set = new HashSet();
while(set.size()<=10)
{
set.add(rand.nextInt(20)+1);
// set.add((int) (Math.random()*21));
}
System.out.println(set);
}
}本回答被提问者和网友采纳