`
nickdine
  • 浏览: 44506 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

hashmap 例子

F# 
阅读更多
public class TestMapUse {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
    Random rand=new Random(159);
    Map<Integer,Integer> sMap=new HashMap<Integer,Integer>();
      for(int index=0;index<10000;index++)
      {
    int r=rand.nextInt(5)+1;
    Integer f=sMap.get(r);
    sMap.put(r, (f==null?1:f+1));
      }
      System.out.println(sMap);
}

}

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics