展开全部
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Random;
public class Test {
public Test() {
super();
}
public static void main(String[] args) {
HashMap hm = new HashMap();//统计用
for(int i = 0 ; i < 10 ; i++){
Random rd = new Random();
int result =rd.nextInt(900000)+100000;
Integer value =hm.get(result);
if(value != null){
hm.put(result, value+1);
}else{
hm.put(result, 1);
}
}
String str = "统计结果为32313133353236313431303231363533e78988e69d8331333335333761:\n";
Iterator ite = hm.entrySet().iterator();
while(ite.hasNext()){
Map.Entry map = (Map.Entry)ite.next();
str = str + map.getKey() +"的数量为:"+map.getValue()+"\n";
}
System.out.println(str);
}
}