auto commit

This commit is contained in:
CyC2018
2019-08-18 23:51:17 +08:00
3 changed files with 30 additions and 11 deletions

View File

@ -63,8 +63,13 @@ boolean 只有两个值true、false可以使用 1 bit 来存储,但是
基本类型都有对应的包装类型基本类型与其对应的包装类型之间的赋值使用自动装箱与拆箱完成
```java
<<<<<<< HEAD
Integer x = 2; // 装箱 调用了 Integer.valueOf(2)
int y = x; // 拆箱 调用了 Integer.intValue(x)
=======
Integer x = 2; // 装箱 调用了 Integer.valueOf(2);
int y = x; // 拆箱 调用了 Integer.intValue(x);
>>>>>>> 7ae8fc396136c44742ab6d5e5a90a3a17fac5af7
```
## 缓存池
@ -78,6 +83,11 @@ new Integer(123) 与 Integer.valueOf(123) 的区别在于:
Integer x = new Integer(123);
Integer y = new Integer(123);
System.out.println(x == y); // false
Integer x = 123; //调用了Integer.valueOf(123);
Integer y = 123; //如果数值在[-128,127]之间便返回指向缓冲池中已经存在的对象的引用否则创建一个新的Integer对象。
System.out.println(x==y); //true
Integer z = Integer.valueOf(123);
Integer k = Integer.valueOf(123);
System.out.println(z == k); // true
@ -154,7 +164,11 @@ System.out.println(m == n); // true
## 概览
<<<<<<< HEAD
String 被声明为 final因此它不可被继承(Integer 等包装类也不能被继承
=======
String 被声明为 final因此它不可被继承(Integer等包装类也不能被继承)
>>>>>>> 7ae8fc396136c44742ab6d5e5a90a3a17fac5af7
Java 8 String 内部使用 char 数组存储数据

View File

@ -650,7 +650,7 @@ static int indexFor(int h, int length) {
| capacity | table 的容量大小默认为 16需要注意的是 capacity 必须保证为 2 n 次方|
| size | 键值对数量 |
| threshold | size 的临界值 size 大于等于 threshold 就必须进行扩容操作 |
| loadFactor | 装载因子table 能够使用的比例threshold = capacity * loadFactor|
| loadFactor | 装载因子table 能够使用的比例threshold = (int)(newCapacity * loadFactor)|
```java
static final int DEFAULT_INITIAL_CAPACITY = 16;
@ -767,7 +767,12 @@ static final int tableSizeFor(int cap) {
### 8. 链表转红黑树
<<<<<<< HEAD
JDK 1.8 开始一个桶存储的链表长度大于等于 8 时会将链表转换为红黑树
=======
JDK 1.8 开始一个桶存储的链表长度大于 8 时会将链表转换为红黑树
应该是 JDK 1.8 开始 table的长度也就是HashMap的capacity(不是size)不能小于64而且在桶存储的链表长度为8时(准确的说是长度为7并且在继续塞第8个时),转换成红黑树,而不是超过8
>>>>>>> 7ae8fc396136c44742ab6d5e5a90a3a17fac5af7
### 9. HashTable 的比较