更新所有文章的图床,旧图床由于一些原因可能会逐渐失效

This commit is contained in:
youthlql
2022-03-15 01:00:37 +08:00
parent ed5227bc89
commit 7c206cc151
52 changed files with 781 additions and 781 deletions

View File

@@ -9,7 +9,7 @@ categories:
- 新特性
keywords: Java8新特性JDK8
description: 详解JDK8出现的新特性。
cover: 'https://unpkg.zhimg.com/youthlql@1.0.8/Java_Basis/logo.png'
cover: 'https://gitee.com/youthlql/randombg/raw/master/logo/java.png'
abbrlink: de3879ae
date: 2020-10-19 22:15:58
---
@@ -20,7 +20,7 @@ date: 2020-10-19 22:15:58
> 本篇文章只讲解比较重要的
<img src="https://unpkg.zhimg.com/youthlql@1.0.8/Java_Basis/Java8_New_Features/0001.png">
<img src="https://img.imlql.cn/youthlql@1.0.8/Java_Basis/Java8_New_Features/0001.png">
@@ -308,13 +308,13 @@ public class LambdaTest1 {
**核心函数式接口**
<img src="https://unpkg.zhimg.com/youthlql@1.0.8/Java_Basis/Java8_New_Features/0002.png">
<img src="https://img.imlql.cn/youthlql@1.0.8/Java_Basis/Java8_New_Features/0002.png">
**其它函数式接口**
<img src="https://unpkg.zhimg.com/youthlql@1.0.8/Java_Basis/Java8_New_Features/0003.png">
<img src="https://img.imlql.cn/youthlql@1.0.8/Java_Basis/Java8_New_Features/0003.png">
@@ -902,7 +902,7 @@ Stream到底是什么呢
<img src="https://unpkg.zhimg.com/youthlql@1.0.8/Java_Basis/Java8_New_Features/0004.png">
<img src="https://img.imlql.cn/youthlql@1.0.8/Java_Basis/Java8_New_Features/0004.png">
@@ -1219,7 +1219,7 @@ public class StreamAPITest2 {
## 常用API
<img src="https://unpkg.zhimg.com/youthlql@1.0.8/Java_Basis/Java8_New_Features/0005.png">
<img src="https://img.imlql.cn/youthlql@1.0.8/Java_Basis/Java8_New_Features/0005.png">

View File

@@ -9,7 +9,7 @@ categories:
- 重难点
keywords: Java基础泛型
description: 万字长文详解Java泛型。
cover: 'https://unpkg.zhimg.com/youthlql@1.0.8/Java_Basis/logo.png'
cover: 'https://gitee.com/youthlql/randombg/raw/master/logo/java.png'
abbrlink: adb2faf0
date: 2020-10-19 22:21:58
---
@@ -1038,7 +1038,7 @@ class Dog extends Animal {
`test1()`在编译时就会飘红
<img src="https://unpkg.zhimg.com/youthlql@1.0.8/Java_Basis/Generic/0001.png">
<img src="https://img.imlql.cn/youthlql@1.0.8/Java_Basis/Generic/0001.png">
@@ -1290,7 +1290,7 @@ public class Test_difference {
}
```
<img src="https://unpkg.zhimg.com/youthlql@1.0.8/Java_Basis/Generic/0002.png">
<img src="https://img.imlql.cn/youthlql@1.0.8/Java_Basis/Generic/0002.png">
### 区别3通配符可以使用超类限定而T不行

View File

@@ -8,7 +8,7 @@ categories:
- HashMap
keywords: Java集合HashMap。
description: HashMap-JDK7源码讲解。
cover: 'https://unpkg.zhimg.com/youthlql@1.0.8/Java_Basis/logo.png'
cover: 'https://gitee.com/youthlql/randombg/raw/master/logo/java.png'
abbrlink: f1f58db2
date: 2020-11-01 10:21:58
---
@@ -202,7 +202,7 @@ hadoop2
大致是这样的一个结构
<img src="https://unpkg.zhimg.com/youthlql@1.0.8/Java_collection/HashMap/JDK7/0001.png">
<img src="https://img.imlql.cn/youthlql@1.0.8/Java_collection/HashMap/JDK7/0001.png">
- 每个链表就算哈希表的桶bucket
- 链表的节点值就算一个键值对
@@ -398,7 +398,7 @@ static class Entry<K,V> implements Map.Entry<K,V> {
`HashMap`中的数组元素 & 链表节点 采用 `Entry`类实现
<img src="https://unpkg.zhimg.com/youthlql@1.0.8/Java_collection/HashMap/JDK7/0001.png">
<img src="https://img.imlql.cn/youthlql@1.0.8/Java_collection/HashMap/JDK7/0001.png">
1、一个正方形代表一个Entry对象同时也代表一个键值对。
@@ -769,15 +769,15 @@ void transfer(Entry[] newTable, boolean rehash) {
大概画了一下图:
<img src="https://unpkg.zhimg.com/youthlql@1.0.8/Java_collection/HashMap/JDK7/0002.png"/>
<img src="https://img.imlql.cn/youthlql@1.0.8/Java_collection/HashMap/JDK7/0002.png"/>
<img src="https://unpkg.zhimg.com/youthlql@1.0.8/Java_collection/HashMap/JDK7/0003.png">
<img src="https://img.imlql.cn/youthlql@1.0.8/Java_collection/HashMap/JDK7/0003.png">
<img src="https://unpkg.zhimg.com/youthlql@1.0.8/Java_collection/HashMap/JDK7/0004.png">
<img src="https://img.imlql.cn/youthlql@1.0.8/Java_collection/HashMap/JDK7/0004.png">
<img src="https://unpkg.zhimg.com/youthlql@1.0.8/Java_collection/HashMap/JDK7/0005.png">
<img src="https://img.imlql.cn/youthlql@1.0.8/Java_collection/HashMap/JDK7/0005.png">
@@ -871,7 +871,7 @@ void transfer(Entry[] newTable, boolean rehash) {
**hashmap初始状态**
<img src="https://unpkg.zhimg.com/youthlql@1.0.8/Java_collection/HashMap/JDK7/0006.png">
<img src="https://img.imlql.cn/youthlql@1.0.8/Java_collection/HashMap/JDK7/0006.png">
@@ -897,7 +897,7 @@ void transfer(Entry[] newTable, boolean rehash) {
**两个线程调用完毕之后hashmap目前是这样的。**
<img src="https://unpkg.zhimg.com/youthlql@1.0.8/Java_collection/HashMap/JDK7/0007.png">
<img src="https://img.imlql.cn/youthlql@1.0.8/Java_collection/HashMap/JDK7/0007.png">
@@ -918,9 +918,9 @@ void transfer(Entry[] newTable, boolean rehash) {
3、来看下此时内存里的状态
<img src="https://unpkg.zhimg.com/youthlql@1.0.8/Java_collection/HashMap/JDK7/0008.png"/>
<img src="https://img.imlql.cn/youthlql@1.0.8/Java_collection/HashMap/JDK7/0008.png"/>
<img src="https://unpkg.zhimg.com/youthlql@1.0.8/Java_collection/HashMap/JDK7/0009.png">
<img src="https://img.imlql.cn/youthlql@1.0.8/Java_collection/HashMap/JDK7/0009.png">
## 步骤4
@@ -957,7 +957,7 @@ void transfer(Entry[] newTable, boolean rehash) {
2、线程2直接**扩容完毕**那么完成后的状态是这样【假设e2和e3还是hash到同一个位置】
<img src="https://unpkg.zhimg.com/youthlql@1.0.8/Java_collection/HashMap/JDK7/0010.png">
<img src="https://img.imlql.cn/youthlql@1.0.8/Java_collection/HashMap/JDK7/0010.png">
3、线程1还是原来的状态
@@ -967,11 +967,11 @@ void transfer(Entry[] newTable, boolean rehash) {
目前两个线程里的新数组是这样的
<img src="https://unpkg.zhimg.com/youthlql@1.0.8/Java_collection/HashMap/JDK7/0011.png">
<img src="https://img.imlql.cn/youthlql@1.0.8/Java_collection/HashMap/JDK7/0011.png">
为了方便后面观看,我画成这样。
<img src="https://unpkg.zhimg.com/youthlql@1.0.8/Java_collection/HashMap/JDK7/0012.png">
<img src="https://img.imlql.cn/youthlql@1.0.8/Java_collection/HashMap/JDK7/0012.png">
@@ -1015,7 +1015,7 @@ void transfer(Entry[] newTable, boolean rehash) {
也就变成了下面这个样子。
<img src="https://unpkg.zhimg.com/youthlql@1.0.8/Java_collection/HashMap/JDK7/0013.png">
<img src="https://img.imlql.cn/youthlql@1.0.8/Java_collection/HashMap/JDK7/0013.png">
@@ -1061,7 +1061,7 @@ void transfer(Entry[] newTable, boolean rehash) {
执行完,变成这样。
<img src="https://unpkg.zhimg.com/youthlql@1.0.8/Java_collection/HashMap/JDK7/0014.png">
<img src="https://img.imlql.cn/youthlql@1.0.8/Java_collection/HashMap/JDK7/0014.png">
@@ -1077,7 +1077,7 @@ void transfer(Entry[] newTable, boolean rehash) {
3、执行pos_3 newTable[i] = e得到 newTable1[3] == e2
<img src="https://unpkg.zhimg.com/youthlql@1.0.8/Java_collection/HashMap/JDK7/0015.png">
<img src="https://img.imlql.cn/youthlql@1.0.8/Java_collection/HashMap/JDK7/0015.png">
这样就形成了循环链表再get()数据就会陷入死循环。

View File

@@ -8,7 +8,7 @@ categories:
- HashMap
keywords: Java集合HashMap。
description: HashMap-JDK8源码讲解及常见面试题。
cover: 'https://unpkg.zhimg.com/youthlql@1.0.8/Java_Basis/logo.png'
cover: 'https://gitee.com/youthlql/randombg/raw/master/logo/java.png'
abbrlink: cbc5672a
date: 2020-11-01 10:22:05
---
@@ -27,7 +27,7 @@ date: 2020-11-01 10:22:05
在JDK8中优化了HashMap的数据结构引入了红黑树。即HashMap的数据结构数组+链表+红黑树。HashMap变成了这样。
<img src="https://unpkg.zhimg.com/youthlql@1.0.8/Java_collection/HashMap/JDK8/0001.png">
<img src="https://img.imlql.cn/youthlql@1.0.8/Java_collection/HashMap/JDK8/0001.png">
### 为什么要引入红黑树
@@ -456,7 +456,7 @@ Process finished with exit code 0
JDK8 hash的运算原理高位参与低位运算使得hash更加均匀。
<img src="https://unpkg.zhimg.com/youthlql@1.0.8/Java_collection/HashMap/JDK8/0002.png">
<img src="https://img.imlql.cn/youthlql@1.0.8/Java_collection/HashMap/JDK8/0002.png">
@@ -569,7 +569,7 @@ JDK8 hash的运算原理高位参与低位运算使得hash更加均匀。
JDK8扩容时数据在数组下标的计算方式
<img src="https://unpkg.zhimg.com/youthlql@1.0.8/Java_collection/HashMap/JDK8/0003.png">
<img src="https://img.imlql.cn/youthlql@1.0.8/Java_collection/HashMap/JDK8/0003.png">
* `JDK8`根据此结论作出的新元素存储位置计算规则非常简单,提高了扩容效率。