文章 2022-05-27 来自:开发者社区

序列化单例模式的实现————readResolve 源码解读 | Java Debug 笔记

序列化单例模式的实现————readResolve 源码解读在可序列化类中加上readResolve方法,就可以实现单例模式了!这是为什么呢?让我们一起看看源码中的奥秘吧!只有实现了序列化接口 Serializable ,才可以进行 序列化操作,测试代码class SingletonTest { */*** ** 序列化测试公共方法* *** *@param* *classNam...

序列化单例模式的实现————readResolve 源码解读 | Java Debug 笔记
文章 2022-05-20 来自:开发者社区

HashMap源码解读—Java8版本(下)

七、阿里面试实战7.1、为什么需要散列表HashMap中的数据结构为散列表,又名哈希表。在这里我会对散列表进行一个简单的介绍,在此之前我们需要先回顾一下 数组、链表 的优缺点。数组:数组删除、插入性能不佳,寻址性能极优链表:链表查询性能不佳,删除、插入性能极优数组的优缺点取决于他们在内存中存储的模式,也就是直接使用顺序存储或链式存储导致的。无论是数组还是链表,都有明显的缺点。而在实际业务中,我们....

HashMap源码解读—Java8版本(下)
文章 2022-05-20 来自:开发者社区

HashMap源码解读—Java8版本(中)

五、构造方法HashMap 共提供了 4 种 构造方法,满足各种常见场景下对容量的需求 // 第1种:创建一个 HashMap 并指定 容量(initialCapacity) 和装载因子(loadFactor) public HashMap(int initialCapacity, float loadFactor) { // 指定容量不可小于0,但可设置为 0 。之后通过...

HashMap源码解读—Java8版本(中)
文章 2022-05-20 来自:开发者社区

HashMap源码解读—Java8版本(上)

一、HashMap简介HashMap顶部有一段很长的注释,大概的介绍了HashMap。1.1 原文/** * Hash table based implementation of the <tt>Map</tt> interface. This * implementation provides all of the optional map operations,...

HashMap源码解读—Java8版本(上)
文章 2022-05-20 来自:开发者社区

LinkedList源码解读—Java8版本(下)

6.1.2 add(int index, E element)方法 // 作用:在指定位置添加元素 public void add(int index, E element) { // 检查插入位置的索引的合理性 checkPositionIndex(index); if (index == size) // 插入的情况是...

文章 2022-05-20 来自:开发者社区

LinkedList源码解读—Java8版本(中)

四、域的解读 // LinkedList节点个数 transient int size = 0; /** * Pointer to first node. 指向头结点 * Invariant: (first == null && last == null) || * (first.prev == null &a...

文章 2022-05-20 来自:开发者社区

LinkedList源码解读—Java8版本(上)

一、LinkedList简介LinkedList顶部有一段很长的注释,大概的介绍了LinkedList。1.1 原文/** * Doubly-linked list implementation of the {@code List} and {@code Deque} * interfaces. Implements all optional list operations, and p...

LinkedList源码解读—Java8版本(上)
文章 2022-05-20 来自:开发者社区

ArrayList源码解读—Java8版本(下)

6.9 clear()方法 /** * Removes all of the elements from this list. The list will * be empty after this call returns. 从列表中删除所有元素。该调用返回后,列表将为空。 */ public void clear() { mo...

ArrayList源码解读—Java8版本(下)
文章 2022-05-20 来自:开发者社区

ArrayList源码解读—Java8版本(中)

五、构造方法ArrayList提供了三种构造方法:ArrayList(int initialCapacity):构造一个指定容量为capacity的空ArrayList。ArrayList():构造一个初始容量为 10 的空列表。ArrayList(Collection<? extends E> c):构造一个包含指定 collection 的元素的列表,这些元素是按照该 colle....

ArrayList源码解读—Java8版本(中)
文章 2022-05-20 来自:开发者社区

ArrayList源码解读—Java8版本(上)

一、ArrayList简介ArrayList顶部有一段很长的注释,大概的介绍了ArrayList。1.1 原文/** * Resizable-array implementation of the <tt>List</tt> interface. Implements * all optional list operations, and permits all e...

ArrayList源码解读—Java8版本(上)

本页面内关键词为智能算法引擎基于机器学习所生成,如有任何问题,可在页面下方点击"联系我们"与我们沟通。

产品推荐

Java开发者

Java开发者成长课堂,课程资料学习,实战案例解析,Java工程师必备词汇等你来~

+关注