几次面试后才弄懂的HashMap
本人大四,以前也开发过几个项目,Map相关集合也总用。但是从来没有研究过底层的实现,只知道杂用。结果在最开始的几次面试中一脸懵逼。认识到不足后,浅显的学习了一下,总结成一下几点。(如果写错了还望指正)
1.HashMap基于Map接口实现,元素以键值对的方式存储,并且允许使用null 建和null值,因为key不能重复,所以只能有一个键为null,另外HashMap不能保证放入元素的顺序,它是无序的,HashMap是线程不安全的。需要同步可以用ConcurrentHashMap和 Collections.synchronizedMap(Map m),推荐使用ConcurrentHashMap,下次会提到它两
2.默认初始化大小16,负载因子0.75
容量是哈希表中桶(Entry数组)的数量,初始容量知识哈希表在创建时的容量。加载因子是哈希表在其容量自动增加之前可以达到多满的一种尺度。当哈希表中的条目数超出了加载因子与当前你容量的乘积时,通过rehash方法将容量翻倍。
3
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAhcAAAD8CAIAAABLpxF3AAATx0lEQVR4Ae3d3W7VxvfG8eSfIECAEGf05RoatUk4AETE26WgSm0vohLX0EpVDnolnLdqVSl3wRniAvjxH+rKCtvexjY78VqzPz2o7PG8POv7TLwYj+Psvn//fsd/CCCAAAIIzCLwf7NaaYQAAggggMAHArKIeYAAAgggMJ+ALDKfnZYIIIAAArKIOYAAAgggMJ+ALDKfnZYIIIAAArKIOYAAAgggMJ+ALDKfnZYIIIAAArKIOYAAAgggMJ+ALDKfnZYIIIAAArKIOYAAAgggMJ+ALDKfnZYIIIAAArKIOYAAAgggMJ/A/qSmBwcHA/XPzs7aq03NbklbYeWgW7NbstKkPe3W7Ja0lVcO2pq1hlZrXMXHWkOrNS6WtQTa205bUg56/+vW7Jb0NiyF3ZrdkjFt19VpyyesRYYnd9tjxoNaQ6s1rjLHTk9PM860MZp/+umnMdXS1WFZOstGCt71Zfh//vnnr7/++v7770ciS1SthPbdd98lEjxSamPZ8fFxfdGV0P7++++jo6PKQmPZyLkdp1pj2eHhYZmNw6omrEWGO8p7tfzQ/vrrr3n1DygvoQ1czXupsazK6EpQv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xMrMDF1CLJIavuIRwABBBYm4InWwgYYvkvAxmyXSboSJqazbLZga5HZ6DREAAEEEPC76+YAAggggMBnELAW+Qx4+ZvamM3v4Q4TKzAxdQiySGr7Nil+5WYU5HSTEW5BX0FcW5GxBeC3OsT9rY5+64P3t80rmAJMrMDE1CF4Ryu1fcQjgAACCxPwRGthAwyPAAIIpCYgi6S2j3gEEEBgYQKyyMIGGB4BBBBITUAWSW0f8QgggMDCBGSRhQ0wPAIIIJCagCyS2j7iEUAAgYUJyCILG2B4BBBAIDUBWSS1fcQjgAACCxOQRRY2wPAIIIBAagKySGr7iEcAAQQWJiCLLGyA4RFAAIHUBGSR1PYRjwACCCxMQBZZ2ADDI4AAAqkJyCKp7SMeAQQQWJiALLKwAYZHAAEEUhOQRVLbRzwCCCCwMAFZZGEDDI8AAgikJiCLpLaPeAQQQGBhArLIwgYYHgEEEEhNQBZJbR/xCCCAwMIEZJGFDTA8AgggkJqALJLaPuIRQACBhQnIIgsbYHgEEEAgNQFZJLV9xCOAAAILE5BFFjbA8AgggEBqArJIavuIRwABBBYmIIssbIDhEUAAgdQEZJHU9hGPAAIILExAFlnYAMMjgAACqQnIIqntIx4BBBBYmIAssrABhkcAAQRSE5BFUttHPAIIILAwgf8HdoDN1wV2iWYAAAAASUVORK5CYIIA" alt="" />
几次面试后才弄懂的HashMap的更多相关文章
- 面试前需要弄懂的SQL
说明:创建数据库 view source print? 1 Create DATABASE database-name 说明:删除数据库 view source print? 1 drop d ...
- 2018前端面试总结,看完弄懂,工资少说加3K | 掘金技术征文
2018前端面试总结,看完弄懂,工资少说加3K | 掘金技术征文:https://juejin.im/post/5b94d8965188255c5a0cdc02
- 彻底弄懂 JavaScript 执行机制
本文的目的就是要保证你彻底弄懂javascript的执行机制,如果读完本文还不懂,可以揍我. 不论你是javascript新手还是老鸟,不论是面试求职,还是日常开发工作,我们经常会遇到这样的情况:给定 ...
- 这一次,彻底弄懂 JavaScript 执行机制
本文转自https://juejin.im/post/59e85eebf265da430d571f89#heading-4 本文的目的就是要保证你彻底弄懂javascript的执行机制,如果读完本文还 ...
- SQL Server-聚焦NOLOCK、UPDLOCK、HOLDLOCK、READPAST你弄懂多少?(三十四)
前言 时间流逝比较快,博主也在快马加鞭学习SQL Server,下班回来再晚也不忘记更新下博客,时间挤挤总会有的,现在的努力求的是未来所谓的安稳,每学一门为的是深度而不是广度,求的是知识自成体系而不是 ...
- 彻底弄懂JS的事件冒泡和事件捕获(不推荐阅读)
由于搬去敌台了,好久没来博客园,今天无意中翻到有“误认子弟”的评论,这里特意做个说明. 本文中关于事件冒泡和事件捕获的描述和例子都是OK的,错就错在后面用jquery去展示了利用事件冒泡的例子有误,其 ...
- 一文弄懂神经网络中的反向传播法——BackPropagation【转】
本文转载自:https://www.cnblogs.com/charlotte77/p/5629865.html 一文弄懂神经网络中的反向传播法——BackPropagation 最近在看深度学习 ...
- [转]js模块化编程之彻底弄懂CommonJS和AMD/CMD!
原文: https://www.cnblogs.com/chenguangliang/p/5856701.html ------------------------------------------ ...
- [转帖]彻底弄懂UTF-8、Unicode、宽字符、locale
彻底弄懂UTF-8.Unicode.宽字符.locale linux后端开发 已关注 彻底弄懂UTF-.Unicode.宽字符.locale unicode 是字符集 utf-8是编码格式.. ...
随机推荐
- python函数高级特性
掌握了Python的数据类型.语句.函数,基本可以编写出很多有用的程序了.但是Python中,代码不是越多越好,而是越少越好.代码不是越复杂越好,而是越简单越好.基于这一思想,我们来介绍python中 ...
- 代理内网上网-iptables
代理内网上网-iptables 1.1 环境说明 主机A:(能上网) ip:内172.16.1.7/24 外10.0.0.7/24 系统CentOS 6.9 主机B:(不能上网) ip:内172.16 ...
- 知乎上看到的关于类.class,对象.getClass
public class TestDemo { //测试 @Test public void fun01() { TestDemo q=new TestDemo(); A a = new A(); q ...
- Redis 学习开发笔记
Redis特点: 1.速度快 2.支持丰富的数据类型:字符串.哈希列表.集合 3.操作具有原子性,所有Redis操作都是原子操作 4.多实用工具,可应用如缓存,消息队列,应用程序中任何短期数据,如we ...
- Gym 100952E&&2015 HIAST Collegiate Programming Contest E. Arrange Teams【DFS+剪枝】
E. Arrange Teams time limit per test:2 seconds memory limit per test:64 megabytes input:standard inp ...
- 94、存储库之MongoDB、mysql
本篇导航: 简介 MongoDB基础知识 安装 基本数据类型 CRUD操作 其它 存储库之mysql 一.简介 MongoDB是一款强大.灵活.且易于扩展的通用型数据库1.易用性 MongoDB是 ...
- POJ 2253 Frogger(Dijkstra变形——最短路径最大权值)
题目链接: http://poj.org/problem?id=2253 Description Freddy Frog is sitting on a stone in the middle of ...
- 炫酷线条动画--svg
我们经常可以在一些页面看到看起来很酷的线条动画,有些可以用css实现,有些css就无能为力了,今天来研究另一种实现方式,svg 如果对svg是什么还不了解的话,可以先去看看svg的基础教程: 一般对于 ...
- 【centos6.5 hadoop2.7 _64位一键安装脚本】有问题加我Q直接问
#!/bin/bash#@author:feiyuanxing [既然笨到家,就要努力到家]#@date:2017-01-05#@E-Mail:feiyuanxing@gmail.com#@TARGE ...
- sizeof(extern类型数组)
error: #70: incomplete type is not allowed 用sizeof计算数组大小,编译器提示不允许使用不完整的类型.在keil上编译直接报错,拿到vs2010上编译可 ...