From b8869607e02847b01dac832c3814be4d1a88cf1e Mon Sep 17 00:00:00 2001 From: LingCoder Date: Mon, 25 Mar 2019 04:56:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=99=84=E5=BD=95=E9=83=A8?= =?UTF-8?q?=E5=88=86=E7=AB=A0=E8=8A=82=E5=AD=90=E6=A0=87=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SUMMARY.md | 126 +++++++++--------- book/Appendix-Becoming-a-Programmer.md | 25 ++++ ...efits-and-Costs-of-Static-Type-Checking.md | 22 +++ book/Appendix-Collection-Topics.md | 71 ++++++++++ book/Appendix-Data-Compression.md | 13 ++ book/Appendix-IO-Streams.md | 30 +++++ book/Appendix-Javadoc.md | 1 + book/Appendix-Low-Level-Concurrency.md | 38 ++++++ book/Appendix-New-IO.md | 19 ++- book/Appendix-Object-Serialization.md | 15 +++ .../Appendix-Passing-and-Returning-Objects.md | 23 ++++ book/Appendix-Programming-Guidelines.md | 11 ++ book/Appendix-Standard-IO.md | 4 + book/Appendix-Supplements.md | 2 +- ...Positive-Legacy-of-C-plus-plus-and-Java.md | 2 +- ...endix-Understanding-equals-and-hashCode.md | 14 +- 16 files changed, 343 insertions(+), 73 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index e7d360e..8e84519 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -335,84 +335,84 @@ * [通过Thinking-in-C来巩固Java基础](book/Appendix-Supplements.md#通过Thinking-in-C来巩固Java基础) * [动手实践](book/Appendix-Supplements.md#动手实践) * [附录:编程指南](book/Appendix-Programming-Guidelines.md) - * [](book/Appendix-Programming-Guidelines.md#) - * [](book/Appendix-Programming-Guidelines.md#) + * [设计](book/Appendix-Programming-Guidelines.md#设计) + * [实现](book/Appendix-Programming-Guidelines.md#实现) * [附录:文档注释](book/Appendix-Javadoc.md) * [附录:对象传递和返回](book/Appendix-Passing-and-Returning-Objects.md) - * [](book/Appendix-Passing-and-Returning-Objects.md#) - * [](book/Appendix-Passing-and-Returning-Objects.md#) - * [](book/Appendix-Passing-and-Returning-Objects.md#) - * [](book/Appendix-Passing-and-Returning-Objects.md#) + * [传递引用](book/Appendix-Passing-and-Returning-Objects.md#传递引用) + * [本地拷贝](book/Appendix-Passing-and-Returning-Objects.md#本地拷贝) + * [控制克隆](book/Appendix-Passing-and-Returning-Objects.md#控制克隆) + * [不可变类](book/Appendix-Passing-and-Returning-Objects.md#不可变类) * [本章小结](book/Appendix-Passing-and-Returning-Objects.md#本章小结) * [附录:流式IO](book/Appendix-IO-Streams.md) - * [](book/Appendix-IO-Streams.md#) - * [](book/Appendix-IO-Streams.md#) - * [](book/Appendix-IO-Streams.md#) - * [](book/Appendix-IO-Streams.md#) - * [](book/Appendix-IO-Streams.md#) - * [](book/Appendix-IO-Streams.md#) + * [输入流类型](book/Appendix-IO-Streams.md#输入流类型) + * [输出流类型](book/Appendix-IO-Streams.md#输出流类型) + * [添加属性和有用的接口](book/Appendix-IO-Streams.md#添加属性和有用的接口) + * [Reader和Writer](book/Appendix-IO-Streams.md#Reader和Writer) + * [RandomAccessFile类](book/Appendix-IO-Streams.md#RandomAccessFile类) + * [IO流典型用途](book/Appendix-IO-Streams.md#IO流典型用途) * [本章小结](book/Appendix-IO-Streams.md#本章小结) * [附录:标准IO](book/Appendix-Standard-IO.md) - * [](book/Appendix-Standard-IO.md#) + * [执行控制](book/Appendix-Standard-IO.md#执行控制) * [附录:新IO](book/Appendix-New-IO.md) - * [](book/Appendix-New-IO.md#) - * [](book/Appendix-New-IO.md#) - * [](book/Appendix-New-IO.md#) - * [](book/Appendix-New-IO.md#) - * [](book/Appendix-New-IO.md#) - * [](book/Appendix-New-IO.md#) - * [](book/Appendix-New-IO.md#) + * [ByteBuffer](book/Appendix-New-IO.md#ByteBuffer) + * [转换数据](book/Appendix-New-IO.md#转换数据) + * [获取原始类型](book/Appendix-New-IO.md#获取原始类型) + * [视图缓冲区](book/Appendix-New-IO.md#视图缓冲区) + * [使用缓冲区进行数据操作](book/Appendix-New-IO.md#使用缓冲区进行数据操作) + * [内存映射文件](book/Appendix-New-IO.md#内存映射文件) + * [文件锁定](book/Appendix-New-IO.md#文件锁定) * [附录:理解equals和hashCode方法](book/Appendix-Understanding-equals-and-hashCode.md) - * [](book/Appendix-Understanding-equals-and-hashCode.md#) - * [](book/Appendix-Understanding-equals-and-hashCode.md#) - * [](book/Appendix-Understanding-equals-and-hashCode.md#) + * [equals典范](book/Appendix-Understanding-equals-and-hashCode.md#equals典范) + * [哈希和哈希码](book/Appendix-Understanding-equals-and-hashCode.md#哈希和哈希码) + * [调整HashMap](book/Appendix-Understanding-equals-and-hashCode.md#调整HashMap) * [附录:集合主题](book/Appendix-Collection-Topics.md) - * [](book/Appendix-Collection-Topics.md#) - * [](book/Appendix-Collection-Topics.md#) - * [](book/Appendix-Collection-Topics.md#) - * [](book/Appendix-Collection-Topics.md#) - * [](book/Appendix-Collection-Topics.md#) - * [](book/Appendix-Collection-Topics.md#) - * [](book/Appendix-Collection-Topics.md#) - * [](book/Appendix-Collection-Topics.md#) - * [](book/Appendix-Collection-Topics.md#) - * [](book/Appendix-Collection-Topics.md#) - * [](book/Appendix-Collection-Topics.md#) - * [](book/Appendix-Collection-Topics.md#) - * [](book/Appendix-Collection-Topics.md#) - * [](book/Appendix-Collection-Topics.md#) - * [](book/Appendix-Collection-Topics.md#) - * [](book/Appendix-Collection-Topics.md#) + * [示例数据](book/Appendix-Collection-Topics.md#示例数据) + * [List表现](book/Appendix-Collection-Topics.md#List表现) + * [Set表现](book/Appendix-Collection-Topics.md#Set表现) + * [在Map中使用函数式操作](book/Appendix-Collection-Topics.md#在Map中使用函数式操作) + * [选择Map的部分](book/Appendix-Collection-Topics.md#选择Map的部分) + * [集合的fill方法](book/Appendix-Collection-Topics.md#集合的fill方法) + * [使用Flyweight自定义集合和Map](book/Appendix-Collection-Topics.md#使用Flyweight自定义集合和Map) + * [集合功能](book/Appendix-Collection-Topics.md#集合功能) + * [可选操作](book/Appendix-Collection-Topics.md#可选操作) + * [Set和存储顺序](book/Appendix-Collection-Topics.md#Set和存储顺序) + * [队列](book/Appendix-Collection-Topics.md#队列) + * [理解Map](book/Appendix-Collection-Topics.md#理解Map) + * [集合工具类](book/Appendix-Collection-Topics.md#集合工具类) + * [持有引用](book/Appendix-Collection-Topics.md#持有引用) + * [避免旧式类库](book/Appendix-Collection-Topics.md#避免旧式类库) + * [本章小结](book/Appendix-Collection-Topics.md#本章小结) * [附录:并发底层原理](book/Appendix-Low-Level-Concurrency.md) - * [](book/Appendix-Low-Level-Concurrency.md#) - * [](book/Appendix-Low-Level-Concurrency.md#) - * [](book/Appendix-Low-Level-Concurrency.md#) - * [](book/Appendix-Low-Level-Concurrency.md#) - * [](book/Appendix-Low-Level-Concurrency.md#) - * [](book/Appendix-Low-Level-Concurrency.md#) - * [](book/Appendix-Low-Level-Concurrency.md#) + * [线程](book/Appendix-Low-Level-Concurrency.md#线程) + * [异常捕获](book/Appendix-Low-Level-Concurrency.md#异常捕获) + * [资源共享](book/Appendix-Low-Level-Concurrency.md#资源共享) + * [volatile关键字](book/Appendix-Low-Level-Concurrency.md#volatile关键字) + * [原子性](book/Appendix-Low-Level-Concurrency.md#原子性) + * [关键部分](book/Appendix-Low-Level-Concurrency.md#关键部分) + * [库组件](book/Appendix-Low-Level-Concurrency.md#库组件) * [本章小结](book/Appendix-Low-Level-Concurrency.md#本章小结) * [附录:数据压缩](book/Appendix-Data-Compression.md) - * [](book/Appendix-Data-Compression.md#) - * [](book/Appendix-Data-Compression.md#) - * [](book/Appendix-Data-Compression.md#) + * [使用Gzip简单压缩](book/Appendix-Data-Compression.md#使用Gzip简单压缩) + * [使用zip多文件存储](book/Appendix-Data-Compression.md#使用zip多文件存储) + * [Java的jar](book/Appendix-Data-Compression.md#Java的jar) * [附录:对象序列化](book/Appendix-Object-Serialization.md) - * [](book/Appendix-Object-Serialization.md#) - * [](book/Appendix-Object-Serialization.md#) - * [](book/Appendix-Object-Serialization.md#) + * [查找类](book/Appendix-Object-Serialization.md#查找类) + * [控制序列化](book/Appendix-Object-Serialization.md#控制序列化) + * [使用持久化](book/Appendix-Object-Serialization.md#使用持久化) * [附录:静态语言类型检查](book/Appendix-Benefits-and-Costs-of-Static-Type-Checking.md) - * [](book/Appendix-Benefits-and-Costs-of-Static-Type-Checking.md#) - * [](book/Appendix-Benefits-and-Costs-of-Static-Type-Checking.md#) - * [](book/Appendix-Benefits-and-Costs-of-Static-Type-Checking.md#) - * [](book/Appendix-Benefits-and-Costs-of-Static-Type-Checking.md#) - * [](book/Appendix-Benefits-and-Costs-of-Static-Type-Checking.md#) + * [前言](book/Appendix-Benefits-and-Costs-of-Static-Type-Checking.md#前言) + * [静态类型检查和测试](book/Appendix-Benefits-and-Costs-of-Static-Type-Checking.md#静态类型检查和测试) + * [如何提升打字](book/Appendix-Benefits-and-Costs-of-Static-Type-Checking.md#如何提升打字) + * [生产力的成本](book/Appendix-Benefits-and-Costs-of-Static-Type-Checking.md#生产力的成本) + * [静态和动态](book/Appendix-Benefits-and-Costs-of-Static-Type-Checking.md#静态和动态) * [附录:C++和Java的优良传统](book/Appendix-The-Positive-Legacy-of-C-plus-plus-and-Java.md) * [附录:成为一名程序员](book/Appendix-Becoming-a-Programmer.md) - * [](book/Appendix-Becoming-a-Programmer.md#) - * [](book/Appendix-Becoming-a-Programmer.md#) - * [](book/Appendix-Becoming-a-Programmer.md#) - * [](book/Appendix-Becoming-a-Programmer.md#) - * [](book/Appendix-Becoming-a-Programmer.md#) - * [](book/Appendix-Becoming-a-Programmer.md#) + * [如何开始](book/Appendix-Becoming-a-Programmer.md#如何开始) + * [码农生涯](book/Appendix-Becoming-a-Programmer.md#码农生涯) + * [百分之五的神话](book/Appendix-Becoming-a-Programmer.md#百分之五的神话) + * [重在动手](book/Appendix-Becoming-a-Programmer.md#重在动手) + * [像打字般编程](book/Appendix-Becoming-a-Programmer.md#像打字般编程) + * [做你喜欢的事](book/Appendix-Becoming-a-Programmer.md#做你喜欢的事) * [词汇表](GLOSSARY.md) diff --git a/book/Appendix-Becoming-a-Programmer.md b/book/Appendix-Becoming-a-Programmer.md index 4fe1fd1..5b7e4c2 100644 --- a/book/Appendix-Becoming-a-Programmer.md +++ b/book/Appendix-Becoming-a-Programmer.md @@ -1,7 +1,32 @@ [TOC] + # 附录:成为一名程序员 + + +## 如何开始 + + + +## 码农生涯 + + + +## 百分之五的神话 + + + +## 重在动手 + + + +## 像打字般编程 + + + +## 做你喜欢的事 +
\ No newline at end of file diff --git a/book/Appendix-Benefits-and-Costs-of-Static-Type-Checking.md b/book/Appendix-Benefits-and-Costs-of-Static-Type-Checking.md index 01c0cd8..071a3c3 100644 --- a/book/Appendix-Benefits-and-Costs-of-Static-Type-Checking.md +++ b/book/Appendix-Benefits-and-Costs-of-Static-Type-Checking.md @@ -1,7 +1,29 @@ [TOC] + # 附录:静态语言类型检查 + + +## 前言 + + + +## 静态类型检查和测试 + + + +## 如何提升打字 + + + +## 生产力的成本 + + + +## 静态和动态 + +
\ No newline at end of file diff --git a/book/Appendix-Collection-Topics.md b/book/Appendix-Collection-Topics.md index 57ea342..f479c55 100644 --- a/book/Appendix-Collection-Topics.md +++ b/book/Appendix-Collection-Topics.md @@ -1,7 +1,78 @@ [TOC] + # 附录:集合主题 + + +## 示例数据 + + + +## List表现 + + + +## Set表现 + + + +## 在Map中使用函数式操作 + + + +## 选择Map的部分 + + + +## 集合的fill方法 + + + +## 使用Flyweight自定义集合和Map + + + +## 集合功能 + + + +## 可选操作 + + + +## Set和存储顺序 + + + +## 队列 + + + +## 理解Map + + + +## 集合工具类 + + + +## 持有引用 + + + +## 避免旧式类库 + + + +## 本章小结 + + + + + + +
\ No newline at end of file diff --git a/book/Appendix-Data-Compression.md b/book/Appendix-Data-Compression.md index d264088..10f4ea2 100644 --- a/book/Appendix-Data-Compression.md +++ b/book/Appendix-Data-Compression.md @@ -1,7 +1,20 @@ [TOC] + # 附录:数据压缩 + + +## 使用Gzip简单压缩 + + + +## 使用zip多文件存储 + + + +## Java的jar +
\ No newline at end of file diff --git a/book/Appendix-IO-Streams.md b/book/Appendix-IO-Streams.md index 51fd15c..56c9342 100644 --- a/book/Appendix-IO-Streams.md +++ b/book/Appendix-IO-Streams.md @@ -1,7 +1,37 @@ [TOC] + # 附录:流式IO + + +## 输入流类型 + + + +## 输出流类型 + + + +## 添加属性和有用的接口 + + + +## Reader和Writer + + + +## RandomAccessFile类 + + + +## IO流典型用途 + + + +## 本章小结 + +
\ No newline at end of file diff --git a/book/Appendix-Javadoc.md b/book/Appendix-Javadoc.md index 3337039..5ea9954 100644 --- a/book/Appendix-Javadoc.md +++ b/book/Appendix-Javadoc.md @@ -1,5 +1,6 @@ [TOC] + # 附录:文档注释 diff --git a/book/Appendix-Low-Level-Concurrency.md b/book/Appendix-Low-Level-Concurrency.md index 3441e7a..9de1eb6 100644 --- a/book/Appendix-Low-Level-Concurrency.md +++ b/book/Appendix-Low-Level-Concurrency.md @@ -1,4 +1,42 @@ [TOC] + # 附录:并发底层原理 + + +## 线程 + + + +## 异常捕获 + + + +## 资源共享 + + + +## volatile关键字 + + + +## 原子性 + + + +## 关键部分 + + + +## 库组件 + + + +## 本章小结 + + + + +
+ diff --git a/book/Appendix-New-IO.md b/book/Appendix-New-IO.md index e4bcbac..da0dee1 100644 --- a/book/Appendix-New-IO.md +++ b/book/Appendix-New-IO.md @@ -1,5 +1,6 @@ [TOC] + # 附录:新IO @@ -11,7 +12,9 @@ Java “新” I/O 库,是在Java 1.4引入到 **Java .nio.* package** 中。 本附录将深入探讨 nio 包。像I/O streams 这样的高级库使用 **nio**,但是大多数时候您不需要在这个级别使用 I/O 。在Java 7和Java 8,您(理想情况下)除了特殊情况外,甚至不需要使用I/O流。理想情况下,您将经常使用的所有内容都包含在文件一章中。只有在处理性能问题 (例如,可能需要内存映射文件)或创建自己的 I/O 库时,才需要理解 **nio**。 -## ByteBuffers + +## ByteBuffer + 直接与通道通信的缓冲区只有一个类型,就是 bytebuffer 。也就是说,一个保存原始字节的缓冲区。如果您查看 **java.nio.ByteBuffer** 的JDK文档,你会发现它很基本 : 您可以通过告诉它要分配多少存储空间来创建一个方法,并且可以使用一些方法来放置和获取数据,这些方法可以是原始字节形式的数据,也可以是原始数据类型的数据。但是没有办法放置或获取对象,甚至字符串。它是相当低层次的,因为这使得大多数操作系统的映射更加有效。 @@ -162,10 +165,11 @@ public class TransferTo { 你不会经常这样做,但知道这一点很好。 - + ## 转换数据 + 在 **GetChannel** 中打印文件中的信息。在 java 中,我们每次提取一个字节的数据,并将每个字节转换为 char。这看起来很简单——如果您查看**java.nio.CharBuffer** 类,您将看到它有一个toString()方法,该方法说,“返回一个包含这个缓冲区中的字符的字符串。” 既然 **ByteBuffer** 可以用 **asCharBuffer()** 方法看作 **CharBuffer**,为什么不使用它呢? 从下面输出语句的第一行可以看出,这并不正确: @@ -322,10 +326,11 @@ gb2312-1980 由于每个字符需要两个字节,这对于12个字符已经足够了,但是“some text”只有9个字节。其余的零字节仍然出现在由其toString()生成的CharBuffer的表示中,如输出所示。 - + ## 获取原始类型 + 虽然 **ByteBuffer** 只包含字节,但它包含了一些方法,用于从它所包含的字节中生成每种不同类型的基元值。这个例子展示了使用以下方法插入和提取各种值: ```java @@ -395,9 +400,9 @@ H o w d y ! 这将对每个基本数据类型执行。其中唯一有点奇怪的是 **ShortBuffer** 的 **put()**,它需要强制转换 (强制转换并更改结果值)。所有其他视图缓冲区都不需要在它们的 **put()** 方法中强制转换。 - ## 视图缓冲区 + “视图缓冲区”通过特定原始类型的窗口来查看底层 **ByteBuffer**。**ByteBuffer** 仍然是“支持”视图的实际存储,因此对视图所做的任何更改都反映在对 **ByteBuffer** 中的数据的修改中。 如前面的示例所示,这方便地将基本类型插入 **ByteBuffer**。视图缓冲区还可以从 **ByteBuffer** 读取原始值,一次读取一个(ByteBuffer允许),或者批量读取(数组)。下面是一个通过 **IntBuffer**在**ByteBuffer** 中操作 int 的例子: @@ -569,9 +574,9 @@ public class Endians { **charArray** 通过 **CharBuffer** 视图插入到 **ByteBuffer **中。当显示底层字节时,默认顺序与随后的大端序相同,而小端序则交换字节。 - ## 使用缓冲区进行数据操作 + 下图说明了 nio 类之间的关系,展示了如何移动和转换数据。例如,要将字节数组写入文件,使用ByteBuffer.wrap() 方法包装字节数组,使用 **getChannel()** 在 **FileOutputStream** 上打开通道,然后从 **ByteBuffer** 将数据写入 **FileChannel**。 ![image-20190324153202297](/Users/langdon/Library/Application Support/typora-user-images/image-20190324153202297.png) @@ -663,9 +668,9 @@ position 指向缓冲区中的第一个元素,capacity 和 limie 紧接在最 再次调用 **symmetricgrab()** 函数时,**CharBuffer** 将经历相同的过程并恢复到原始状态。 - ## 内存映射文件 + 内存映射文件允许您创建和修改太大而无法放入内存的文件。使用内存映射文件,您可以假装整个文件都在内存中,并将其视为一个非常大的数组来访问它。这种方法大大简化了您编写的修改文件的代码: ```java @@ -864,8 +869,8 @@ Mapped Read/Write: 0.013 请注意,**test()** 方法包括初始化各种I/O对象的时间,因此,尽管映射文件的设置可能很昂贵,但是与流I/O相比,总体收益非常可观。 +## 文件锁定 -### 文件锁定 文件锁定同步访问,因此文件可以是共享资源。但是,争用同一个文件的两个线程可能位于不同的jvm 中,可能一个是 Java 线程,另一个是操作系统中的某个本机线程。文件锁定对其他操作系统进程是可见的,因为Java文件锁定直接映射到本机操作系统锁定工具。 diff --git a/book/Appendix-Object-Serialization.md b/book/Appendix-Object-Serialization.md index 3f60e3c..646dd1b 100644 --- a/book/Appendix-Object-Serialization.md +++ b/book/Appendix-Object-Serialization.md @@ -1,7 +1,22 @@ [TOC] + # 附录:对象序列化 + + +## 查找类 + + + +## 控制序列化 + + + +## 使用持久化 + + +
\ No newline at end of file diff --git a/book/Appendix-Passing-and-Returning-Objects.md b/book/Appendix-Passing-and-Returning-Objects.md index b2a45a0..de6d712 100644 --- a/book/Appendix-Passing-and-Returning-Objects.md +++ b/book/Appendix-Passing-and-Returning-Objects.md @@ -1,7 +1,30 @@ [TOC] + # 附录:对象传递和返回 + + +## 传递引用 + + + +## 本地拷贝 + + + +## 控制克隆 + + + +## 不可变类 + + + +## 本章小结 + + +
\ No newline at end of file diff --git a/book/Appendix-Programming-Guidelines.md b/book/Appendix-Programming-Guidelines.md index 0bf4676..2d654a1 100644 --- a/book/Appendix-Programming-Guidelines.md +++ b/book/Appendix-Programming-Guidelines.md @@ -1,7 +1,18 @@ [TOC] + # 附录:编程指南 + + +## 设计 + + + +## 实现 + + +
\ No newline at end of file diff --git a/book/Appendix-Standard-IO.md b/book/Appendix-Standard-IO.md index 96da9bc..eab20ad 100644 --- a/book/Appendix-Standard-IO.md +++ b/book/Appendix-Standard-IO.md @@ -1,7 +1,11 @@ [TOC] + # 附录:标准IO + +## 执行控制 +
\ No newline at end of file diff --git a/book/Appendix-Supplements.md b/book/Appendix-Supplements.md index 5afdb74..e5cc791 100644 --- a/book/Appendix-Supplements.md +++ b/book/Appendix-Supplements.md @@ -15,6 +15,6 @@ ## 动手实践 - +
\ No newline at end of file diff --git a/book/Appendix-The-Positive-Legacy-of-C-plus-plus-and-Java.md b/book/Appendix-The-Positive-Legacy-of-C-plus-plus-and-Java.md index f35da00..fb26815 100644 --- a/book/Appendix-The-Positive-Legacy-of-C-plus-plus-and-Java.md +++ b/book/Appendix-The-Positive-Legacy-of-C-plus-plus-and-Java.md @@ -1,8 +1,8 @@ [TOC] + # 附录:C++和Java的优良传统 -
diff --git a/book/Appendix-Understanding-equals-and-hashCode.md b/book/Appendix-Understanding-equals-and-hashCode.md index 15e2fa5..1dafbdc 100644 --- a/book/Appendix-Understanding-equals-and-hashCode.md +++ b/book/Appendix-Understanding-equals-and-hashCode.md @@ -1,7 +1,19 @@ [TOC] + # 附录:理解equals和hashCode方法 - + +## equals典范 + + + +## 哈希和哈希码 + + + +## 调整HashMap + +
\ No newline at end of file