想从list中随机取几条数据,请高手赐教!
解决方案 »
- 对数据库的数据判断后显示
- J2EE工作一年后应该达到什么水平
- 诠释 j2ee 规范 的例子最高官方提供的示例
- 关于 spring 配置连接池问题,进来看看吧!!!!
- hibernate 联合查询 问题 ?(criteria)
- Struts数据源(请高手指点,我是初学者,谢谢)
- 关于隐式对象的一个示例错误困惑中,急!!!
- 有无可直接用的用户管理,像ASP.net中可直接加入工程里的?
- weblogic/version错误!
- sqlserver连接问题,我快疯了!解决了随你要多少分!
- axis2 访问同样的asmx,速度特别慢,不知道是否正常,请各位大虾赐教
- Axis下WebService,call.invoke()方法总是返回空值,提供的服务也没调用
list.get(r.nextInt(list.length());如此循环几次
int maxcount = 5;
int nowindex = -1;
int length = list.length
List indexlist = new ArrayList();//最好方法外定义每次clear
int count = 0;
Random r = new Random();
while(count < 5){
nowindex = r.nextInt(length);
if(indexlist.indexOf(""+nowindex) == -1){
indexlist.add(""+nowindex);
count++;
//取出数据
} else{continue;}}