java development skills

1. Collection

  • To use hashmap, you need to initialize the capacity. The formula is the desired map size/0.75+1
  • Map traversal should use entrySet instead of keyset
    /**
    * 最常见也是大多数情况下用的最多的,一般在键值对都需要使用
     */
    Map <String,String>map = new HashMap<String,String>();
    map.put("熊大", "棕色");
    map.put("熊二", "黄色");
    for(Map.Entry<String, String> entry : map.entrySet()){
        String mapKey = entry.getKey();
        String mapValue = entry.getValue();
        System.out.println(mapKey+":"+mapValue);
    }
    9

     -----To be expanded

おすすめ

転載: blog.csdn.net/weixin_59244784/article/details/132796473