几次面试后才弄懂的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是编码格式.. ...
随机推荐
- pycharm中进行带参数的调试
之前基本都是用print进行调试的,但今天程序运行完需要等很长时间,就尝试pycharm调试. 但是在运行程序需要传递参数,之前只会点击bug按钮直接运行程序,不知道调试的时候传入参数. 运行---& ...
- PHP开发工程师应该具备那些技术能力
根据各大招聘网站的数据分析,2017年IT行业,其中从事软件开发和数据分析的毕业生的月薪最高.究其原因是因为随着互联网的不断发展,岗位人才稀缺,需求量大.那么如何快速的成为软件开发人员,比如PHP开发 ...
- .NET Core:使用ImageSharp跨平台处理图像
一.简述 ImageSharp是一个新的跨平台2D图形API,旨在处理图像而不使用System.Drawing. 二.安装 目前ImageSharp还是处于alpha版本,所以我们需要在nuget中添 ...
- React-Native 学习笔记-Android开发平台-开发环境搭建
详细步骤请查看官网对应文档,BUT,有些注意事项请注意! 1,优先安装Node.js,因为后面可以使用npm安装软件, 2,注意不要使用CNPM!!!!!!!!! 3,Android Studio 请 ...
- 洛谷 P3410 拍照
洛谷 P3410 拍照 题目描述 小B有n个下属,现小B要带着一些下属让别人拍照. 有m个人,每个人都愿意付给小B一定钱让n个人中的一些人进行合影.如果这一些人没带齐那么就不能拍照,小B也不会得到钱. ...
- cs231n spring 2017 lecture1 Introduction to Convolutional Neural Networks for Visual Recognition 听课笔记
1. 生物学家做实验发现脑皮层对简单的结构比如角.边有反应,而通过复杂的神经元传递,这些简单的结构最终帮助生物体有了更复杂的视觉系统.1970年David Marr提出的视觉处理流程遵循这样的原则,拿 ...
- 认识Sass和Compass
第一章 Sass和Compass让样式表重焕青春 // 内容概要// 开始学习Sass和动态样式表// 用Sass更高效地写样式表// Compass简介// 用Compass迎接工程实践中的样式挑战 ...
- train problem I (栈水题)
杭电1002http://acm.hdu.edu.cn/showproblem.php?pid=1022 Train Problem I Time Limit: 2000/1000 MS (Java/ ...
- MIT公开课:算法导论 笔记(一)
课程链接:http://open.163.com/special/opencourse/algorithms.html 第一课:算法分析基础 1.介绍插入排序与归并排序,计算并比较最坏运行时间 2.算 ...
- ucosii --任务就绪表
任务就绪表的任务就是高效的找出当前优先级最高的就绪任务. 由任务就绪表OSRdyTbl和任务就绪组OSRdyGrb组成,OSRdyTbl每一个位都记录着一个任务的就绪状态, 0非就绪1就绪,OSRdy ...