让生成的随机数不重复,我该怎么该代码!急上加急!
我的代码如下:
class RandomNum
{
int a,b,c;
RandomNum()
{
for(int i=0;i<54;i++)
{
b=(int)(Math.random()*54+1);
System.out.print(b+",");
}
}
public static void main(String args[])
{
new RandomNum();
}
}
我测试了下,有重复的数字出现,请问有什么办法,让循环内的数字不重复,而且54个数都要有