Java 产生不重复的随机数



int numberCount = 6;
Set set = new TreeSet();
while (set.size() < numberCount) {
int number = (int) (Math.random() * 33)+1;
if (!set.contains(number)) {
set.add(number);
}
}
// out.println(set);
String result=set.toString().substring(1,set.toString().length()-1);
// result=result.lastIndexOf(",");
// out.println(result);
for(int i=0;i // Iterator ite=ts.iterator();
}


int team=Integer.parseInt(request.getParameter("team"));
String[] str=(String[])request.getSession().getAttribute("fnstr");
for(int i=0;i out.println(str[i]);
}

你可能感兴趣的:(JAVA,Java)