├── .gitignore ├── LICENSE ├── README.md ├── day1 ├── 1.2_3.4_image.png ├── 1.2_4.1_image.png ├── 1.2_4.1_s.png ├── FloatAnalysis.java ├── IntTest.java └── IntegerTest.java ├── day2 └── FloatTest.java ├── day3 ├── Person.java ├── Person2.java ├── Person3.java ├── Person4.java ├── SerializationExample.java ├── SerializationExample2.java ├── SerializationExample3.java └── SerializationExample4.java ├── day4 └── FloatTest.java ├── day5 ├── WaitNotifyAllTest.java ├── WaitNotifyAllTest2.java ├── WaitNotifyAllTest3.java ├── WaitNotifyAllTest4.java ├── WaitNotifyAllTest5.java └── wait_question_image1.png ├── day7 └── FloatTest.java ├── day9 └── FloatTest.java └── project └── day2 ├── serial_port_image1.png ├── serial_port_image2.png ├── serial_port_image3.png ├── serial_port_image4.png └── serial_port_image5.png /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | /.idea/navEditor.xml 9 | /.idea/assetWizardSettings.xml 10 | /build 11 | /captures 12 | .externalNativeBuild 13 | .cxx 14 | 15 | 16 | # Built application files 17 | #*.apk 18 | #*.ap_ 19 | 20 | # Files for the ART/Dalvik VM 21 | *.dex 22 | 23 | # Java class files 24 | *.class 25 | 26 | # Generated files 27 | bin/ 28 | gen/ 29 | out/ 30 | 31 | # Gradle files 32 | .gradle/ 33 | build/ 34 | 35 | # Local configuration file (sdk path, etc) 36 | local.properties 37 | 38 | # Proguard folder generated by Eclipse 39 | proguard/ 40 | 41 | # Log Files 42 | *.log 43 | 44 | # Android Studio Navigation editor temp files 45 | .navigation/ 46 | 47 | # Android Studio captures folder 48 | captures/ 49 | 50 | # Intellij 51 | *.iml 52 | .idea/workspace.xml 53 | .idea/tasks.xml 54 | .idea/gradle.xml 55 | .idea/dictionaries 56 | .idea/libraries 57 | .idea/ 58 | /out/ 59 | out/ 60 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Java专栏精品博客 2 | #### 目录介绍 3 | - 01.Java专栏介绍 4 | - 02.Java高级进阶 5 | - 03.JVM虚拟机进阶 6 | - 04.数据集合设计 7 | - 05.更多内容推荐 8 | 9 | 10 | 11 | ## 01.Java专栏介绍 12 | Java高级进阶专栏博客,数据类型原理,泛型设计思想,面向对象,继承,封装,io流,序列化,拷贝,高效读写,反射,注解,spi机制,异常,四种引用,线程原理,线程通信,线程池设计思想,线程并发优化,上下文切换原理,CAS,锁的设计和原理,类加载,对象布局,代码攻击,内存模型,即时编译,内存回收机制,性能调优,集合设计思想。 13 | 14 | 15 | 16 | ## 02.Java高级进阶 17 | - [1.1String深入理解原理](https://yccoding.com/zh/java/advanced/1.1String%E6%B7%B1%E5%85%A5%E7%90%86%E8%A7%A3%E5%8E%9F%E7%90%86.html) 18 | - [1.2浮点型数据深入研究](https://yccoding.com/zh/java/advanced/1.2%E6%B5%AE%E7%82%B9%E5%9E%8B%E6%95%B0%E6%8D%AE%E6%B7%B1%E5%85%A5%E7%A0%94%E7%A9%B6.html) 19 | - [1.3数据装箱和拆箱原理](https://yccoding.com/zh/java/advanced/1.3%E6%95%B0%E6%8D%AE%E8%A3%85%E7%AE%B1%E5%92%8C%E6%8B%86%E7%AE%B1%E5%8E%9F%E7%90%86.html) 20 | - [1.4泛型由来和设计思想](https://yccoding.com/zh/java/advanced/1.4%E6%B3%9B%E5%9E%8B%E7%94%B1%E6%9D%A5%E5%92%8C%E8%AE%BE%E8%AE%A1%E6%80%9D%E6%83%B3.html) 21 | - [1.5加密和解密设计和原理](https://yccoding.com/zh/java/advanced/1.5%E5%8A%A0%E5%AF%86%E5%92%8C%E8%A7%A3%E5%AF%86%E8%AE%BE%E8%AE%A1%E5%92%8C%E5%8E%9F%E7%90%86.html) 22 | - [2.1面向对象设计思想](https://yccoding.com/zh/java/advanced/2.1%E9%9D%A2%E5%90%91%E5%AF%B9%E8%B1%A1%E8%AE%BE%E8%AE%A1%E6%80%9D%E6%83%B3.html) 23 | - [2.2抽象类和接口设计](https://yccoding.com/zh/java/advanced/2.2%E6%8A%BD%E8%B1%A1%E7%B1%BB%E5%92%8C%E6%8E%A5%E5%8F%A3%E8%AE%BE%E8%AE%A1.html) 24 | - [2.3封装和继承设计思想](https://yccoding.com/zh/java/advanced/2.3%E5%B0%81%E8%A3%85%E5%92%8C%E7%BB%A7%E6%89%BF%E8%AE%BE%E8%AE%A1%E6%80%9D%E6%83%B3.html) 25 | - [2.4复用和组合设计思想](https://yccoding.com/zh/java/advanced/2.4%E5%A4%8D%E7%94%A8%E5%92%8C%E7%BB%84%E5%90%88%E8%AE%BE%E8%AE%A1%E6%80%9D%E6%83%B3.html) 26 | - [2.5对象和引用设计思想](http://localhost:8080/zh/java/advanced/2.5%E5%AF%B9%E8%B1%A1%E5%92%8C%E5%BC%95%E7%94%A8%E8%AE%BE%E8%AE%A1%E6%80%9D%E6%83%B3.html) 27 | - [3.1IO流设计思想和原理](http://localhost:8080/zh/java/advanced/3.1IO%E6%B5%81%E8%AE%BE%E8%AE%A1%E6%80%9D%E6%83%B3%E5%92%8C%E5%8E%9F%E7%90%86.html) 28 | - [3.2为何设计序列化数据](http://localhost:8080/zh/java/advanced/3.2%E4%B8%BA%E4%BD%95%E8%AE%BE%E8%AE%A1%E5%BA%8F%E5%88%97%E5%8C%96%E6%95%B0%E6%8D%AE.html) 29 | - [3.3各种拷贝数据比较](http://localhost:8080/zh/java/advanced/3.3%E5%90%84%E7%A7%8D%E6%8B%B7%E8%B4%9D%E6%95%B0%E6%8D%AE%E6%AF%94%E8%BE%83.html) 30 | - [3.4高效文件读写的原理](http://localhost:8080/zh/java/advanced/3.4%E9%AB%98%E6%95%88%E6%96%87%E4%BB%B6%E8%AF%BB%E5%86%99%E7%9A%84%E5%8E%9F%E7%90%86.html) 31 | - [4.1反射性能探索和优化](http://localhost:8080/zh/java/advanced/4.1%E5%8F%8D%E5%B0%84%E6%80%A7%E8%83%BD%E6%8E%A2%E7%B4%A2%E5%92%8C%E4%BC%98%E5%8C%96.html) 32 | - [4.2为何要设计注解思想](http://localhost:8080/zh/java/advanced/4.2%E4%B8%BA%E4%BD%95%E8%A6%81%E8%AE%BE%E8%AE%A1%E6%B3%A8%E8%A7%A3%E6%80%9D%E6%83%B3.html) 33 | - [4.3动态代理的设计思想](http://localhost:8080/zh/java/advanced/4.3%E5%8A%A8%E6%80%81%E4%BB%A3%E7%90%86%E7%9A%84%E8%AE%BE%E8%AE%A1%E6%80%9D%E6%83%B3.html) 34 | - [4.4SPI机制设计的思想](http://localhost:8080/zh/java/advanced/4.4SPI%E6%9C%BA%E5%88%B6%E8%AE%BE%E8%AE%A1%E7%9A%84%E6%80%9D%E6%83%B3.html) 35 | - [4.5异常设计和捕获原理](http://localhost:8080/zh/java/advanced/4.5%E5%BC%82%E5%B8%B8%E8%AE%BE%E8%AE%A1%E5%92%8C%E6%8D%95%E8%8E%B7%E5%8E%9F%E7%90%86.html) 36 | - [4.6虚拟机如何处理异常](http://localhost:8080/zh/java/advanced/4.6%E8%99%9A%E6%8B%9F%E6%9C%BA%E5%A6%82%E4%BD%95%E5%A4%84%E7%90%86%E5%BC%82%E5%B8%B8.html) 37 | - [4.7四种引用设计思想](http://localhost:8080/zh/java/advanced/4.7%E5%9B%9B%E7%A7%8D%E5%BC%95%E7%94%A8%E8%AE%BE%E8%AE%A1%E6%80%9D%E6%83%B3.html) 38 | - [5.1线程的前世今生探索](http://localhost:8080/zh/java/advanced/5.1%E7%BA%BF%E7%A8%8B%E7%9A%84%E5%89%8D%E4%B8%96%E4%BB%8A%E7%94%9F%E6%8E%A2%E7%B4%A2.html) 39 | - [5.2线程通信的设计思想](http://localhost:8080/zh/java/advanced/5.2%E7%BA%BF%E7%A8%8B%E9%80%9A%E4%BF%A1%E7%9A%84%E8%AE%BE%E8%AE%A1%E6%80%9D%E6%83%B3.html) 40 | - [5.3线程监控和Debug设计](http://localhost:8080/zh/java/advanced/5.3%E7%BA%BF%E7%A8%8B%E7%9B%91%E6%8E%A7%E5%92%8CDebug%E8%AE%BE%E8%AE%A1.html) 41 | - [5.4线程和JVM之间联系](http://localhost:8080/zh/java/advanced/5.4%E7%BA%BF%E7%A8%8B%E5%92%8CJVM%E4%B9%8B%E9%97%B4%E8%81%94%E7%B3%BB.html) 42 | - [5.5线程池使用技巧介绍](http://localhost:8080/zh/java/advanced/5.5%E7%BA%BF%E7%A8%8B%E6%B1%A0%E4%BD%BF%E7%94%A8%E6%8A%80%E5%B7%A7%E4%BB%8B%E7%BB%8D.html) 43 | - [5.6线程池设计核心原理](http://localhost:8080/zh/java/advanced/5.6%E7%BA%BF%E7%A8%8B%E6%B1%A0%E8%AE%BE%E8%AE%A1%E6%A0%B8%E5%BF%83%E5%8E%9F%E7%90%86.html) 44 | - [5.7线程如何最大优化](http://localhost:8080/zh/java/advanced/5.7%E7%BA%BF%E7%A8%8B%E5%A6%82%E4%BD%95%E6%9C%80%E5%A4%A7%E4%BC%98%E5%8C%96.html) 45 | - [6.1多线程并发经典案例](http://localhost:8080/zh/java/advanced/6.1%E5%A4%9A%E7%BA%BF%E7%A8%8B%E5%B9%B6%E5%8F%91%E7%BB%8F%E5%85%B8%E6%A1%88%E4%BE%8B.html) 46 | - [6.2并发安全前世今生](http://localhost:8080/zh/java/advanced/6.2%E5%B9%B6%E5%8F%91%E5%AE%89%E5%85%A8%E5%89%8D%E4%B8%96%E4%BB%8A%E7%94%9F.html) 47 | - [6.3线程安全如何保证](http://localhost:8080/zh/java/advanced/6.3%E7%BA%BF%E7%A8%8B%E5%AE%89%E5%85%A8%E5%A6%82%E4%BD%95%E4%BF%9D%E8%AF%81.html) 48 | - [6.4变量的线程安全探索](http://localhost:8080/zh/java/advanced/6.4%E5%8F%98%E9%87%8F%E7%9A%84%E7%BA%BF%E7%A8%8B%E5%AE%89%E5%85%A8%E6%8E%A2%E7%B4%A2.html) 49 | - [6.5并发上下文切换原理](http://localhost:8080/zh/java/advanced/6.5%E5%B9%B6%E5%8F%91%E4%B8%8A%E4%B8%8B%E6%96%87%E5%88%87%E6%8D%A2%E5%8E%9F%E7%90%86.html) 50 | - [6.6理解CAS设计和由来](http://localhost:8080/zh/java/advanced/6.6%E7%90%86%E8%A7%A3CAS%E8%AE%BE%E8%AE%A1%E5%92%8C%E7%94%B1%E6%9D%A5.html) 51 | - [6.7协程设计思想和原理](http://localhost:8080/zh/java/advanced/6.7%E5%8D%8F%E7%A8%8B%E8%AE%BE%E8%AE%A1%E6%80%9D%E6%83%B3%E5%92%8C%E5%8E%9F%E7%90%86.html) 52 | - [6.8事物并发模型解读](http://localhost:8080/zh/java/advanced/6.8%E4%BA%8B%E7%89%A9%E5%B9%B6%E5%8F%91%E6%A8%A1%E5%9E%8B%E8%A7%A3%E8%AF%BB.html) 53 | - [6.9并发设计模型研究](http://localhost:8080/zh/java/advanced/6.9%E5%B9%B6%E5%8F%91%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%9E%8B%E7%A0%94%E7%A9%B6.html) 54 | - [6.10并发编程数据一致性](http://localhost:8080/zh/java/advanced/6.10%E5%B9%B6%E5%8F%91%E7%BC%96%E7%A8%8B%E6%95%B0%E6%8D%AE%E4%B8%80%E8%87%B4%E6%80%A7.html) 55 | - [6.11锁问题的定位和修复](http://localhost:8080/zh/java/advanced/6.11%E9%94%81%E9%97%AE%E9%A2%98%E7%9A%84%E5%AE%9A%E4%BD%8D%E5%92%8C%E4%BF%AE%E5%A4%8D.html) 56 | - [6.12多线程如何性能调优](http://localhost:8080/zh/java/advanced/6.12%E5%A4%9A%E7%BA%BF%E7%A8%8B%E5%A6%82%E4%BD%95%E6%80%A7%E8%83%BD%E8%B0%83%E4%BC%98.html) 57 | - [7.1类的加载过程和原理](http://localhost:8080/zh/java/advanced/7.1%E7%B1%BB%E7%9A%84%E5%8A%A0%E8%BD%BD%E8%BF%87%E7%A8%8B%E5%92%8C%E5%8E%9F%E7%90%86.html) 58 | - [7.2对象布局设计的原理](http://localhost:8080/zh/java/advanced/7.2%E5%AF%B9%E8%B1%A1%E5%B8%83%E5%B1%80%E8%AE%BE%E8%AE%A1%E7%9A%84%E5%8E%9F%E7%90%86.html) 59 | - [7.3双亲委派机制设计思想](http://localhost:8080/zh/java/advanced/7.3%E5%8F%8C%E4%BA%B2%E5%A7%94%E6%B4%BE%E6%9C%BA%E5%88%B6%E8%AE%BE%E8%AE%A1%E6%80%9D%E6%83%B3.html) 60 | - [7.5代码攻击和安全防护](http://localhost:8080/zh/java/advanced/7.5%E4%BB%A3%E7%A0%81%E6%94%BB%E5%87%BB%E5%92%8C%E5%AE%89%E5%85%A8%E9%98%B2%E6%8A%A4.html) 61 | - [7.6设计动态生成Java类](http://localhost:8080/zh/java/advanced/7.6%E8%AE%BE%E8%AE%A1%E5%8A%A8%E6%80%81%E7%94%9F%E6%88%90Java%E7%B1%BB.html) 62 | 63 | 64 | 65 | 66 | ## 03.JVM虚拟机进阶 67 | - [8.1彻底搞透彻内存模型](http://localhost:8080/zh/java/jvm/8.1%E5%BD%BB%E5%BA%95%E6%90%9E%E9%80%8F%E5%BD%BB%E5%86%85%E5%AD%98%E6%A8%A1%E5%9E%8B.html) 68 | - [8.2JVM内存回收清理机制](http://localhost:8080/zh/java/jvm/8.2JVM%E5%86%85%E5%AD%98%E5%9B%9E%E6%94%B6%E6%B8%85%E7%90%86%E6%9C%BA%E5%88%B6.html) 69 | - [8.3JVM监控和故障处理](http://localhost:8080/zh/java/jvm/8.3JVM%E7%9B%91%E6%8E%A7%E5%92%8C%E6%95%85%E9%9A%9C%E5%A4%84%E7%90%86.html) 70 | - [8.4JVM如何执行方法调用](http://localhost:8080/zh/java/jvm/8.4JVM%E5%A6%82%E4%BD%95%E6%89%A7%E8%A1%8C%E6%96%B9%E6%B3%95%E8%B0%83%E7%94%A8.html) 71 | - [8.5JVM如何实现invoked](http://localhost:8080/zh/java/jvm/8.5JVM%E5%A6%82%E4%BD%95%E5%AE%9E%E7%8E%B0invoked.html) 72 | - [8.6JVM性能调优的策略](http://localhost:8080/zh/java/jvm/8.6JVM%E6%80%A7%E8%83%BD%E8%B0%83%E4%BC%98%E7%9A%84%E7%AD%96%E7%95%A5.html) 73 | - [8.7内存上升排查和优化](http://localhost:8080/zh/java/jvm/8.7%E5%86%85%E5%AD%98%E4%B8%8A%E5%8D%87%E6%8E%92%E6%9F%A5%E5%92%8C%E4%BC%98%E5%8C%96.html) 74 | - [8.8JVM即时编译器原理](http://localhost:8080/zh/java/jvm/8.8JVM%E5%8D%B3%E6%97%B6%E7%BC%96%E8%AF%91%E5%99%A8%E5%8E%9F%E7%90%86.html) 75 | - [8.9JVM性能如何调优实践](http://localhost:8080/zh/java/jvm/8.9JVM%E6%80%A7%E8%83%BD%E5%A6%82%E4%BD%95%E8%B0%83%E4%BC%98%E5%AE%9E%E8%B7%B5.html) 76 | 77 | 78 | 79 | 80 | ## 04.数据集合设计 81 | - [9.1数据集合设计思想解读](https://yccoding.com/zh/java/collection/9.1%E6%95%B0%E6%8D%AE%E9%9B%86%E5%90%88%E8%AE%BE%E8%AE%A1%E6%80%9D%E6%83%B3%E8%A7%A3%E8%AF%BB.html) 82 | - [9.2ArrayList设计思想](https://yccoding.com/zh/java/collection/9.2ArrayList%E8%AE%BE%E8%AE%A1%E6%80%9D%E6%83%B3.html) 83 | - [9.3LinkedList设计思想](https://yccoding.com/zh/java/collection/9.3LinkedList%E8%AE%BE%E8%AE%A1%E6%80%9D%E6%83%B3.html) 84 | - [9.4HashMap源码设计思想](https://yccoding.com/zh/java/collection/9.4HashMap%E6%BA%90%E7%A0%81%E8%AE%BE%E8%AE%A1%E6%80%9D%E6%83%B3.html) 85 | - [9.5TreeMap设计思想](https://yccoding.com/zh/java/collection/9.5TreeMap%E8%AE%BE%E8%AE%A1%E6%80%9D%E6%83%B3.html) 86 | - [9.6HashSet设计思想](https://yccoding.com/zh/java/collection/9.6HashSet%E8%AE%BE%E8%AE%A1%E6%80%9D%E6%83%B3.html) 87 | - [9.7LinkedHashMap设计思想](https://yccoding.com/zh/java/collection/9.7LinkedHashMap%E8%AE%BE%E8%AE%A1%E6%80%9D%E6%83%B3.html) 88 | - [9.8CopyOnWriteArrayList设计](https://yccoding.com/zh/java/collection/9.8CopyOnWriteArrayList%E8%AE%BE%E8%AE%A1.html) 89 | - [9.9ConcurrentHashMap设计](https://yccoding.com/zh/java/collection/9.9ConcurrentHashMap%E8%AE%BE%E8%AE%A1.html) 90 | 91 | 92 | 93 | 94 | 95 | 96 | ## 05.更多内容推荐 97 | | 模块 | 描述 | 备注 | 98 | |---------|-------------------------------------------------|----------------------------------------------------------| 99 | | GitHub | 多个YC系列开源项目,包含Android组件库,以及多个案例 | [GitHub](https://github.com/yangchong211) | 100 | | 博客汇总 | 汇聚Java,Android,C/C++,网络协议,算法,编程总结等 | [YCBlogs](https://github.com/yangchong211/YCBlogs) | 101 | | 设计模式 | 六大设计原则,23种设计模式,设计模式案例,面向对象思想 | [设计模式](https://github.com/yangchong211/YCDesignBlog) | 102 | | Java进阶 | 数据设计和原理,面向对象核心思想,IO,异常,线程和并发,JVM | [Java高级](https://github.com/yangchong211/YCJavaBlog) | 103 | | 网络协议 | 网络实际案例,网络原理和分层,Https,网络请求,故障排查 | [网络协议](https://github.com/yangchong211/YCNetwork) | 104 | | 计算机原理 | 计算机组成结构,框架,存储器,CPU设计,内存设计,指令编程原理,异常处理机制,IO操作和原理 | [计算机基础](https://github.com/yangchong211/YCComputerBlog) | 105 | | 学习C编程 | C语言入门级别系统全面的学习教程,学习三到四个综合案例 | [C编程](https://github.com/yangchong211/YCStudyC) | 106 | | C++编程 | C++语言入门级别系统全面的教学教程,并发编程,核心原理 | [C++编程](https://github.com/yangchong211/YCStudyCpp) | 107 | | 算法实践 | 专栏,数组,链表,栈,队列,树,哈希,递归,查找,排序等 | [Leetcode](https://github.com/yangchong211/YCLeetcode) | 108 | | Android | 基础入门,开源库解读,性能优化,Framework,方案设计 | [Android](https://github.com/yangchong211/YCAndroidBlog) | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | -------------------------------------------------------------------------------- /day1/1.2_3.4_image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yangchong211/YCJavaBlog/5a758d927e1c8faf659690ab59ce842119d85042/day1/1.2_3.4_image.png -------------------------------------------------------------------------------- /day1/1.2_4.1_image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yangchong211/YCJavaBlog/5a758d927e1c8faf659690ab59ce842119d85042/day1/1.2_4.1_image.png -------------------------------------------------------------------------------- /day1/1.2_4.1_s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yangchong211/YCJavaBlog/5a758d927e1c8faf659690ab59ce842119d85042/day1/1.2_4.1_s.png -------------------------------------------------------------------------------- /day1/FloatAnalysis.java: -------------------------------------------------------------------------------- 1 | package day1; 2 | 3 | 4 | import java.util.Arrays; 5 | import java.util.concurrent.TimeUnit; 6 | 7 | /** 8 | * 浮点数底层研究 9 | **/ 10 | public class FloatAnalysis{ 11 | 12 | public static void main(String[] args) throws Exception { 13 | // 需要计算真实存储值的浮点数 14 | float floatValue1 = 16.35f; 15 | float floatValue2 = .35f; 16 | System.out.println(floatValue1 + "的真实存储值:" + rayFloatStudy(floatValue1)); 17 | System.out.println("\n========我是一条华丽的分割线========\n"); 18 | System.out.println(floatValue2 + "的真实存储值:" + rayFloatStudy(floatValue2)); 19 | 20 | 21 | double f1 = FloatAnalysis.rayFloatStudy(0.1f); 22 | double f2 = FloatAnalysis.rayFloatStudy(0.2f); 23 | double f3 = FloatAnalysis.rayFloatStudy(0.3f); 24 | System.out.println(f1 + "\t= 0.1f"); // 0.10000000149011612 = 0.1f 25 | System.out.println(f2 + "\t= 0.2f"); // 0.20000000298023224 = 0.2f 26 | System.out.println(f3 + "\t= 0.3f"); // 0.30000001192092896 = 0.3f 27 | 28 | 29 | double f4 = FloatAnalysis.rayFloatStudy(1.4f); 30 | System.out.println(f4 + "\t= 1.4f"); 31 | double f5 = FloatAnalysis.rayFloatStudy(1.5f); 32 | System.out.println(f5 + "\t= 1.5f"); 33 | } 34 | 35 | /** 36 | * 解析浮点数组成 37 | * 38 | * @param floatValue 待解析的浮点数 39 | * @author LiaoYuXing-Ray 2024/1/4 10:01 40 | **/ 41 | public static double rayFloatStudy(float floatValue) throws Exception { 42 | // 符号位(1位) 43 | byte[] symbol = new byte[1]; 44 | // 阶码位(8位),指数部分 45 | byte[] exponent = new byte[8]; 46 | // 尾数位(23位),有效数字 47 | byte[] number = new byte[23]; 48 | 49 | String binaryRepresentation = floatToBinary(floatValue); 50 | 51 | System.out.println("浮点数\t" + floatValue); 52 | System.out.println("========开始解析每一位的含义========"); 53 | System.out.println(binaryRepresentation); 54 | byte[] byteString = binaryRepresentation.getBytes(); 55 | // float 4字节 1字节=8bit 所以32 56 | byte[] byteArray = new byte[32]; 57 | // ASCII码中48是0 49是1 58 | for (int i = 0; i < byteString.length; i++) { 59 | if (byteString[i] == 48) { 60 | byteArray[i] = 0; 61 | } else if (byteString[i] == 49) { 62 | byteArray[i] = 1; 63 | } else { 64 | throw new Exception("不应该出现的分支,理论上转为二进制只有0和1"); 65 | } 66 | } 67 | 68 | /* 69 | 以下是获取符号位、指数部分、有效数字的值,并输出 70 | */ 71 | for (int i = 0; i < byteArray.length; i++) { 72 | if (i == 0) { 73 | symbol[i] = byteArray[i]; 74 | } 75 | if (i >= 1 && i <= 8) { 76 | exponent[i - 1] = byteArray[i]; 77 | } 78 | if (i > 8) { 79 | number[i - 9] = byteArray[i]; 80 | } 81 | // 以下为输出,可注释 82 | if (i != 0 && i % 4 == 0) { 83 | System.out.print("-"); 84 | } 85 | System.out.print(byteArray[i]); 86 | } 87 | 88 | System.out.print("\n符号位值(1位):" + Arrays.toString(symbol)); 89 | if (symbol[0] == 0) { 90 | System.out.print("为正数"); 91 | } else if (symbol[0] == 1) { 92 | System.out.print("为负数"); 93 | } else { 94 | throw new Exception("不应该出现的分支,符号位理论上只有0和1两种情况"); 95 | } 96 | 97 | System.out.print("\n指数部分(8位):["); 98 | for (byte b : exponent) { 99 | System.out.print(b); 100 | } 101 | System.out.print("]\t-> 转化十进制数:[" + binaryToDecimal(exponent) + "]"); 102 | 103 | System.out.print("\n有效数字(23位):["); 104 | for (byte b : number) { 105 | System.out.print(b); 106 | } 107 | System.out.print("]"); 108 | 109 | System.out.println("\n=======还原float的真实存储值======="); 110 | 111 | // 指数部分的十进制数值 112 | int exponentOfDecimalNumber = binaryToDecimal(exponent); 113 | /* 114 | 以 IEEE754 标准规定,单精度的阶码偏移量为 2^(n-1)-1 (即127),这样能表示的指数范围为 [-126,127] 115 | */ 116 | // 阶码偏移量 117 | int offsetExponent = exponentOfDecimalNumber - 127; 118 | System.out.println("阶码偏移量=指数部分的十进制数值[" + exponentOfDecimalNumber + "]- [2^(n-1)-1 (即127)]=" + offsetExponent); 119 | 120 | // 指数值。此处double是因为Math.pow方法的参数为double类型 121 | double integerBitsBaseValue; 122 | if (offsetExponent >= 0) { 123 | integerBitsBaseValue = 1 << offsetExponent; 124 | } else { 125 | integerBitsBaseValue = Math.pow(2D, offsetExponent); 126 | } 127 | System.out.println("指数值=2^阶码偏移量[" + offsetExponent + "]=" + integerBitsBaseValue); 128 | 129 | // 整数部分(小数点左边的部分)即整数位(基础值) 130 | double integerBits = integerBitsBaseValue; 131 | 132 | // 有效位数转化为10进制数 133 | double tempCount; 134 | if (offsetExponent >= 0) { 135 | tempCount = 1D; 136 | // 如果偏移量大于等于0,整数部分为0 137 | integerBits = 0; 138 | System.out.println("整数部分(小数点左边的部分)即整数位(基础值)=" + integerBits); 139 | System.out.println("尾数23位实际为1.xxx,尾数为有效数字加上1.0"); 140 | System.out.print("所以有效位数的二进制表示为[1."); 141 | 142 | } else { 143 | tempCount = 0D; 144 | System.out.println("整数部分(小数点左边的部分)即整数位(基础值):" + integerBits); 145 | System.out.println("尾数23位部分为0.xxx,尾数为有效数字加上0.0"); 146 | System.out.print("所以有效位数的二进制表示为[0."); 147 | } 148 | 149 | /* 150 | 此处计算小数二进制转化为十进制,比如0.01(2)=0*2^(-1)+1*2^(-2)=0.25(10) 151 | */ 152 | for (int i = 0; i < number.length; i++) { 153 | if (number[i] == 1) { 154 | // 将2的负(i+1)次方累加 155 | tempCount += Math.pow(2, -(i + 1)); 156 | } 157 | System.out.print(number[i]); 158 | } 159 | System.out.println("] -> 有效位数10进制数的值" + tempCount); 160 | 161 | // 小数有效值 162 | double decimalEffectiveValue = tempCount * integerBitsBaseValue; 163 | System.out.println("(有效位数10进制数的值" + tempCount + ")*(指数值" + integerBitsBaseValue + ")=小数有效值:" + decimalEffectiveValue); 164 | double result = decimalEffectiveValue + integerBits; 165 | if (byteArray[0] == 0) { 166 | System.err.println(floatValue + "为正数,小数有效值[" + decimalEffectiveValue + "]加上整数部分[" + integerBits + "],最终结果:" + result); 167 | } else { 168 | System.err.println(floatValue + "为负数结果需要*(-1),小数有效值[" + decimalEffectiveValue + "]加上整数部分[" + integerBits + "],最终结果:" + (result * -1)); 169 | } 170 | 171 | // 休眠是因为防止err语句输出顺序混乱 172 | try { 173 | TimeUnit.MILLISECONDS.sleep(50); 174 | } catch (InterruptedException e) { 175 | e.printStackTrace(); 176 | } 177 | return result; 178 | } 179 | 180 | /** 181 | * 长度为8的byte[]转换为对应的十进制数 182 | * 183 | * @param exponentBytes 长度为8的byte[] 184 | * @return int 185 | * @author LiaoYuXing-Ray 2024/1/4 10:01 186 | **/ 187 | private static int binaryToDecimal(byte[] exponentBytes) { 188 | int decimal = 0; 189 | for (int i = 0; i < exponentBytes.length; i++) { 190 | decimal += (exponentBytes[i] & 0xFF) * Math.pow(2, exponentBytes.length - 1 - i); 191 | } 192 | return decimal; 193 | } 194 | 195 | /** 196 | * 浮点型转化为bit,字符串输出,会自动补零 197 | * 198 | * @param value 浮点数 199 | * @return java.lang.String 200 | * @author LiaoYuXing-Ray 2024/1/4 10:01 201 | **/ 202 | private static String floatToBinary(float value) { 203 | int intBits = Float.floatToIntBits(value); 204 | return String.format("%32s", Integer.toBinaryString(intBits)).replace(' ', '0'); 205 | } 206 | } 207 | 208 | 209 | -------------------------------------------------------------------------------- /day1/IntTest.java: -------------------------------------------------------------------------------- 1 | package day1; 2 | 3 | public class IntTest { 4 | 5 | public static void main(String[] args) { 6 | //装箱:将基本类型转化为包装类型 7 | Integer i = 10; 8 | //拆箱:将包装类型转化为基本类型 9 | int c = i; 10 | } 11 | 12 | 13 | public class Student { 14 | 15 | private int age; 16 | 17 | public void setAge(T t) { 18 | 19 | } 20 | 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /day1/IntegerTest.java: -------------------------------------------------------------------------------- 1 | package day1; 2 | 3 | public class IntegerTest { 4 | 5 | public static void main(String[] args) { 6 | 7 | 8 | // Integer i = new Integer(100); 9 | // Integer j = new Integer(100); 10 | // System.out.print(i == j); //false 11 | 12 | Integer i = new Integer(100); 13 | int j = 100; 14 | System.out.print(i == j); //true 15 | } 16 | 17 | 18 | } 19 | -------------------------------------------------------------------------------- /day2/FloatTest.java: -------------------------------------------------------------------------------- 1 | package day2; 2 | 3 | public class FloatTest { 4 | 5 | public static void main(String[] args) { 6 | test1(); 7 | test2(); 8 | } 9 | 10 | private static void test1() { 11 | float a = 2.0000001F; 12 | float b = 2.0000001F; 13 | System.out.println(a == b); // 输出true 14 | System.out.println(0.1f + 0.2f == 0.3f); // 输出true 15 | System.out.println(0.1 + 0.2 == 0.3); // 输出false 16 | System.out.println(0.3f + 0.6f == 0.9f); // 输出false 17 | System.out.println(0.3 + 0.6 == 0.9); // 输出false 18 | System.out.println(0.6 + 0.6 == 1.2); // 输出true 19 | System.out.println(0.2 + 0.2 == 0.4); // 输出true 20 | 21 | //打印结果 22 | //true 23 | //true 24 | //false 25 | //false 26 | //false 27 | //true 28 | //true 29 | } 30 | 31 | private static void test2() { 32 | float f = 1.4f; 33 | double d = 1.4d; 34 | float f1 = 1.5f; 35 | double d1 = 1.5d; 36 | 37 | System.out.println(f); //1.4 38 | System.out.println((double)f); //1.399999976158142 39 | System.out.println(d); //1.4 40 | System.out.println(f - d); //-2.3841857821338408E-8 41 | System.out.println(f == d); //false 42 | 43 | System.out.println("--------"); 44 | System.out.println(f1); //1.5 45 | System.out.println((double) f1); //1.5 46 | System.out.println(d1); //1.5 47 | System.out.println(f1 - d1); //0.0 48 | System.out.println(f1 == d1); //true 49 | 50 | 51 | //1.4 52 | //1.399999976158142 53 | //1.4 54 | //-2.3841857821338408E-8 55 | //false 56 | //-------- 57 | //1.5 58 | //1.5 59 | //1.5 60 | //0.0 61 | //true 62 | } 63 | 64 | } 65 | 66 | -------------------------------------------------------------------------------- /day3/Person.java: -------------------------------------------------------------------------------- 1 | package day3; 2 | 3 | import java.io.IOException; 4 | import java.io.ObjectInputStream; 5 | import java.io.ObjectOutputStream; 6 | import java.io.Serializable; 7 | 8 | public class Person implements Serializable { 9 | 10 | private String name; 11 | private int age; 12 | private transient String address; // The field marked as transient will not be serialized 13 | 14 | public Person(String name, int age, String address) { 15 | this.name = name; 16 | this.age = age; 17 | this.address = address; 18 | } 19 | 20 | private void writeObject(ObjectOutputStream out) throws IOException { 21 | // Manually control the serialization process 22 | out.defaultWriteObject(); // Default serialization of name and age fields 23 | // Custom serialization for the address field 24 | out.writeUTF(address); 25 | } 26 | 27 | private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { 28 | // Manually control the deserialization process 29 | in.defaultReadObject(); // Default deserialization of name and age fields 30 | // Custom deserialization for the address field 31 | address = in.readUTF(); 32 | } 33 | 34 | @Override 35 | public String toString() { 36 | return "Person [name=" + name + ", age=" + age + ", address=" + address + "]"; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /day3/Person2.java: -------------------------------------------------------------------------------- 1 | package day3; 2 | 3 | import java.io.Serializable; 4 | 5 | public class Person2 implements Serializable { 6 | private String name; 7 | private transient int age; // 使用transient关键字修饰的字段不会被序列化 8 | 9 | public Person2(String name, int age) { 10 | this.name = name; 11 | this.age = age; 12 | } 13 | 14 | @Override 15 | public String toString() { 16 | return "Person2 [name=" + name + ", age=" + age + "]"; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /day3/Person3.java: -------------------------------------------------------------------------------- 1 | package day3; 2 | 3 | import java.io.IOException; 4 | import java.io.ObjectInputStream; 5 | import java.io.ObjectOutputStream; 6 | import java.io.Serializable; 7 | 8 | public class Person3 implements Serializable { 9 | 10 | private String name; 11 | private int age; 12 | private transient String address; // The field marked as transient will not be serialized 13 | private transient long cardId; 14 | 15 | public Person3(String name, int age, String address , long cardId) { 16 | this.name = name; 17 | this.age = age; 18 | this.address = address; 19 | this.cardId = cardId; 20 | } 21 | 22 | private void writeObject(ObjectOutputStream out) throws IOException { 23 | // Manually control the serialization process 24 | out.defaultWriteObject(); // Default serialization of name and age fields 25 | // Custom serialization for the address field 26 | out.writeUTF(address); 27 | out.writeLong(cardId); 28 | } 29 | 30 | private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { 31 | // Manually control the deserialization process 32 | in.defaultReadObject(); // Default deserialization of name and age fields 33 | // Custom deserialization for the address field 34 | address = in.readUTF(); 35 | cardId = in.readLong(); 36 | } 37 | 38 | @Override 39 | public String toString() { 40 | return "Person [name=" + name + ", age=" + age + ", address=" + address + ", cardId=" + cardId + "]"; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /day3/Person4.java: -------------------------------------------------------------------------------- 1 | package day3; 2 | 3 | import java.io.IOException; 4 | import java.io.ObjectInputStream; 5 | import java.io.ObjectOutputStream; 6 | import java.io.Serializable; 7 | 8 | public class Person4 implements Serializable { 9 | 10 | // private static final long serialVersionUID = 1L; 11 | private String name; 12 | private int age; 13 | private transient String address; // The field marked as transient will not be serialized 14 | private transient long cardId; 15 | 16 | public Person4(String name, int age, String address , long cardId) { 17 | this.name = name; 18 | this.age = age; 19 | this.address = address; 20 | this.cardId = cardId; 21 | } 22 | 23 | private void writeObject(ObjectOutputStream out) throws IOException { 24 | // Manually control the serialization process 25 | out.defaultWriteObject(); // Default serialization of name and age fields 26 | // Custom serialization for the address field 27 | out.writeUTF(address); 28 | out.writeLong(cardId); 29 | } 30 | 31 | private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { 32 | // Manually control the deserialization process 33 | in.defaultReadObject(); // Default deserialization of name and age fields 34 | // Custom deserialization for the address field 35 | address = in.readUTF(); 36 | cardId = in.readLong(); 37 | } 38 | 39 | @Override 40 | public String toString() { 41 | return "Person [name=" + name + ", age=" + age + ", address=" + address + ", cardId=" + cardId + "]"; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /day3/SerializationExample.java: -------------------------------------------------------------------------------- 1 | package day3; 2 | 3 | import java.io.*; 4 | 5 | public class SerializationExample { 6 | 7 | public static void main(String[] args) { 8 | Person person = new Person("打工充", 30, "湖北武汉"); 9 | try { 10 | //写数据 11 | FileOutputStream fileOut = new FileOutputStream("person.txt"); 12 | ObjectOutputStream out = new ObjectOutputStream(fileOut); 13 | out.writeObject(person); // Manually call writeObject to serialize 14 | out.close(); 15 | fileOut.close(); 16 | 17 | //读数据 18 | FileInputStream fileIn = new FileInputStream("person.txt"); 19 | ObjectInputStream in = new ObjectInputStream(fileIn); 20 | Person restoredPerson = (Person) in.readObject(); // Manually call readObject to deserialize 21 | in.close(); 22 | fileIn.close(); 23 | 24 | System.out.println("Original Person: " + person); 25 | System.out.println("Restored Person: " + restoredPerson); 26 | } catch (IOException e) { 27 | e.printStackTrace(); 28 | } catch (ClassNotFoundException e) { 29 | e.printStackTrace(); 30 | } 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /day3/SerializationExample2.java: -------------------------------------------------------------------------------- 1 | package day3; 2 | 3 | import java.io.*; 4 | 5 | public class SerializationExample2 { 6 | 7 | public static void main(String[] args) { 8 | Person2 person = new Person2("打工充", 30); 9 | try { 10 | FileOutputStream fileOut = new FileOutputStream("person.txt"); 11 | ObjectOutputStream out = new ObjectOutputStream(fileOut); 12 | out.writeObject(person); // 序列化Person2对象 13 | out.close(); 14 | fileOut.close(); 15 | FileInputStream fileIn = new FileInputStream("person.txt"); 16 | ObjectInputStream in = new ObjectInputStream(fileIn); 17 | Person2 restoredPerson2 = (Person2) in.readObject(); // 反序列化为Person2对象 18 | in.close(); 19 | fileIn.close(); 20 | System.out.println("Original Person2: " + person); 21 | System.out.println("Restored Person2: " + restoredPerson2); 22 | } catch (IOException e) { 23 | e.printStackTrace(); 24 | } catch (ClassNotFoundException e) { 25 | e.printStackTrace(); 26 | } 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /day3/SerializationExample3.java: -------------------------------------------------------------------------------- 1 | package day3; 2 | 3 | import java.io.*; 4 | 5 | public class SerializationExample3 { 6 | 7 | public static void main(String[] args) { 8 | Person3 person = new Person3("打工充", 30,"武汉", 2143324); 9 | try { 10 | // FileOutputStream fileOut = new FileOutputStream("person.txt"); 11 | // ObjectOutputStream out = new ObjectOutputStream(fileOut); 12 | // out.writeObject(person); 13 | // out.close(); 14 | // fileOut.close(); 15 | 16 | FileInputStream fileIn = new FileInputStream("person.txt"); 17 | ObjectInputStream in = new ObjectInputStream(fileIn); 18 | Person3 restoredPerson2 = (Person3) in.readObject(); // 反序列化为Person2对象 19 | in.close(); 20 | fileIn.close(); 21 | System.out.println("Original Person3: " + person); 22 | System.out.println("Restored Person3: " + restoredPerson2); 23 | 24 | //Original Person3: Person [name=打工充, age=30, address=武汉, cardId=2143324] 25 | //Restored Person3: Person [name=打工充, age=30, address=武汉, cardId=2143324] 26 | } catch (IOException e) { 27 | e.printStackTrace(); 28 | } catch (ClassNotFoundException e) { 29 | e.printStackTrace(); 30 | } 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /day3/SerializationExample4.java: -------------------------------------------------------------------------------- 1 | package day3; 2 | 3 | import java.io.*; 4 | 5 | public class SerializationExample4 { 6 | 7 | public static void main(String[] args) { 8 | // Person4 person = new Person4("打工充", 30,"武汉", 2143324); 9 | try { 10 | // FileOutputStream fileOut = new FileOutputStream("person.txt"); 11 | // ObjectOutputStream out = new ObjectOutputStream(fileOut); 12 | // out.writeObject(person); 13 | // out.close(); 14 | // fileOut.close(); 15 | 16 | FileInputStream fileIn = new FileInputStream("person.txt"); 17 | ObjectInputStream in = new ObjectInputStream(fileIn); 18 | Person4 restoredPerson2 = (Person4) in.readObject(); // 反序列化为Person2对象 19 | in.close(); 20 | fileIn.close(); 21 | // System.out.println("Original Person3: " + person); 22 | System.out.println("Restored Person3: " + restoredPerson2); 23 | 24 | //Original Person3: Person [name=打工充, age=30, address=武汉, cardId=2143324] 25 | //Restored Person3: Person [name=打工充, age=30, address=武汉, cardId=2143324] 26 | } catch (IOException e) { 27 | e.printStackTrace(); 28 | } catch (ClassNotFoundException e) { 29 | e.printStackTrace(); 30 | } 31 | } 32 | 33 | 34 | 35 | } 36 | -------------------------------------------------------------------------------- /day4/FloatTest.java: -------------------------------------------------------------------------------- 1 | package day4; 2 | 3 | public class FloatTest { 4 | 5 | public static void main(String[] args) { 6 | test1(); 7 | test2(); 8 | } 9 | 10 | private static void test1() { 11 | float a = 2.0000001F; 12 | float b = 2.0000001F; 13 | System.out.println(a == b); // 输出true 14 | System.out.println(0.1f + 0.2f == 0.3f); // 输出true 15 | System.out.println(0.1 + 0.2 == 0.3); // 输出false 16 | System.out.println(0.3f + 0.6f == 0.9f); // 输出false 17 | System.out.println(0.3 + 0.6 == 0.9); // 输出false 18 | System.out.println(0.6 + 0.6 == 1.2); // 输出true 19 | System.out.println(0.2 + 0.2 == 0.4); // 输出true 20 | 21 | //打印结果 22 | //true 23 | //true 24 | //false 25 | //false 26 | //false 27 | //true 28 | //true 29 | } 30 | 31 | private static void test2() { 32 | float f = 1.4f; 33 | double d = 1.4d; 34 | float f1 = 1.5f; 35 | double d1 = 1.5d; 36 | 37 | System.out.println(f); //1.4 38 | System.out.println((double)f); //1.399999976158142 39 | System.out.println(d); //1.4 40 | System.out.println(f - d); //-2.3841857821338408E-8 41 | System.out.println(f == d); //false 42 | 43 | System.out.println("--------"); 44 | System.out.println(f1); //1.5 45 | System.out.println((double) f1); //1.5 46 | System.out.println(d1); //1.5 47 | System.out.println(f1 - d1); //0.0 48 | System.out.println(f1 == d1); //true 49 | 50 | 51 | //1.4 52 | //1.399999976158142 53 | //1.4 54 | //-2.3841857821338408E-8 55 | //false 56 | //-------- 57 | //1.5 58 | //1.5 59 | //1.5 60 | //0.0 61 | //true 62 | } 63 | 64 | } 65 | 66 | -------------------------------------------------------------------------------- /day5/WaitNotifyAllTest.java: -------------------------------------------------------------------------------- 1 | package day5; 2 | 3 | public class WaitNotifyAllTest { 4 | 5 | public static void main(String[] args) { 6 | // 创建饭菜对象 7 | KitChenRoom chenRoom = new KitChenRoom(); 8 | // 创建小明妈妈线程,做饭 9 | new Thread(() -> { 10 | for (int i = 0; i < 3; i++) { 11 | chenRoom.cook(); 12 | } 13 | },"小明妈妈线程:").start(); 14 | // 创建小明自己线程,吃饭 15 | new Thread(() -> { 16 | for (int i = 0; i < 3; i++) { 17 | chenRoom.eat(); 18 | } 19 | },"小明自己线程:").start(); 20 | } 21 | 22 | public static class KitChenRoom { 23 | // 是否有吃的 24 | private boolean hasFood = false; 25 | // 设置同步锁,做饭和吃饭只能同时有一个在执行,不能边做边吃 26 | private final Object lock = new Object(); 27 | // 做饭 28 | public void cook() { 29 | // 加锁 30 | synchronized (lock) { 31 | // 如果有吃的,就不做饭 32 | if(hasFood) { 33 | // 还有吃的,先不做饭 34 | try { 35 | lock.wait(); 36 | } catch (InterruptedException e) { 37 | throw new RuntimeException(e); 38 | } 39 | } 40 | // 否则就做饭, 41 | System.out.println(Thread.currentThread().getName() + "没吃的了,给娃做饭!"); 42 | // 做好之后,修改为true 43 | hasFood = true; 44 | // 通知其他线程吃饭 45 | lock.notifyAll(); 46 | } 47 | } 48 | 49 | // 吃饭 50 | public void eat() { 51 | synchronized (lock) { 52 | // 如果没吃的,就喊妈妈做饭,暂时吃不了 53 | if (!hasFood) { 54 | try { 55 | lock.wait(); 56 | } catch (InterruptedException e) { 57 | throw new RuntimeException(e); 58 | } 59 | } 60 | // 否则就吃饭 61 | System.out.println(Thread.currentThread().getName() + "感谢老妈,恰饭,恰饭"); 62 | // 吃完之后,修改为false 63 | hasFood = false; 64 | // 通知其他线程吃饭 65 | lock.notifyAll(); 66 | } 67 | } 68 | } 69 | } 70 | 71 | -------------------------------------------------------------------------------- /day5/WaitNotifyAllTest2.java: -------------------------------------------------------------------------------- 1 | package day5; 2 | 3 | public class WaitNotifyAllTest2 { 4 | 5 | public static void main(String[] args) { 6 | // 创建饭菜对象 7 | KitChenRoom chenRoom = new KitChenRoom(); 8 | // 创建小明妈妈线程,做饭 9 | new Thread(() -> { 10 | for (int i = 0; i < 3; i++) { 11 | chenRoom.cook(); 12 | } 13 | },"小明妈妈线程:").start(); 14 | // 爸爸线程:做饭 15 | new Thread(() -> { 16 | for (int i = 0; i < 3; i++) { 17 | chenRoom.cook(); 18 | } 19 | },"小明爸爸线程:").start(); 20 | // 创建小明自己线程,吃饭 21 | new Thread(() -> { 22 | for (int i = 0; i < 3; i++) { 23 | chenRoom.eat(); 24 | } 25 | },"小明自己线程:").start(); 26 | // 大明线程:吃饭 27 | new Thread(() -> { 28 | for (int i = 0; i < 3; i++) { 29 | chenRoom.eat(); 30 | } 31 | },"大明哥哥线程:").start(); 32 | } 33 | 34 | public static class KitChenRoom { 35 | // 是否有吃的 36 | private boolean hasFood = false; 37 | // 设置同步锁,做饭和吃饭只能同时有一个在执行,不能边做边吃 38 | private final Object lock = new Object(); 39 | // 做饭 40 | public void cook() { 41 | // 加锁 42 | synchronized (lock) { 43 | // 如果有吃的,就不做饭 44 | if(hasFood) { 45 | // 还有吃的,先不做饭 46 | try { 47 | lock.wait(); 48 | } catch (InterruptedException e) { 49 | throw new RuntimeException(e); 50 | } 51 | } 52 | // 否则就做饭, 53 | System.out.println(Thread.currentThread().getName() + "没吃的了,给娃做饭!"); 54 | // 做好之后,修改为true 55 | hasFood = true; 56 | // 通知其他线程吃饭 57 | lock.notifyAll(); 58 | } 59 | } 60 | 61 | // 吃饭 62 | public void eat() { 63 | synchronized (lock) { 64 | // 如果没吃的,就喊妈妈做饭,暂时吃不了 65 | if (!hasFood) { 66 | try { 67 | lock.wait(); 68 | } catch (InterruptedException e) { 69 | throw new RuntimeException(e); 70 | } 71 | } 72 | // 否则就吃饭 73 | System.out.println(Thread.currentThread().getName() + "感谢老妈,恰饭,恰饭"); 74 | // 吃完之后,修改为false 75 | hasFood = false; 76 | // 通知其他线程吃饭 77 | lock.notifyAll(); 78 | } 79 | } 80 | } 81 | } 82 | 83 | -------------------------------------------------------------------------------- /day5/WaitNotifyAllTest3.java: -------------------------------------------------------------------------------- 1 | package day5; 2 | 3 | public class WaitNotifyAllTest3 { 4 | 5 | public static void main(String[] args) { 6 | // 创建饭菜对象 7 | KitChenRoom chenRoom = new KitChenRoom(); 8 | // 创建小明妈妈线程,做饭 9 | new Thread(() -> { 10 | for (int i = 0; i < 3; i++) { 11 | chenRoom.cook(); 12 | } 13 | },"小明妈妈线程:").start(); 14 | // 爸爸线程:做饭 15 | new Thread(() -> { 16 | for (int i = 0; i < 3; i++) { 17 | chenRoom.cook(); 18 | } 19 | },"小明爸爸线程:").start(); 20 | // 创建小明自己线程,吃饭 21 | new Thread(() -> { 22 | for (int i = 0; i < 3; i++) { 23 | chenRoom.eat(); 24 | } 25 | },"小明自己线程:").start(); 26 | // 大明线程:吃饭 27 | new Thread(() -> { 28 | for (int i = 0; i < 3; i++) { 29 | chenRoom.eat(); 30 | } 31 | },"大明哥哥线程:").start(); 32 | } 33 | 34 | public static class KitChenRoom { 35 | // 是否有吃的 36 | private boolean hasFood = false; 37 | // 设置同步锁,做饭和吃饭只能同时有一个在执行,不能边做边吃 38 | private final Object lock = new Object(); 39 | // 做饭 40 | public void cook() { 41 | // 加锁 42 | synchronized (lock) { 43 | // 如果有吃的,就不做饭 44 | while(hasFood) { 45 | // 还有吃的,先不做饭 46 | try { 47 | lock.wait(); 48 | } catch (InterruptedException e) { 49 | throw new RuntimeException(e); 50 | } 51 | } 52 | // 否则就做饭, 53 | System.out.println(Thread.currentThread().getName() + "没吃的了,给娃做饭!"); 54 | // 做好之后,修改为true 55 | hasFood = true; 56 | // 通知其他线程吃饭 57 | lock.notifyAll(); 58 | } 59 | } 60 | 61 | // 吃饭 62 | public void eat() { 63 | synchronized (lock) { 64 | // 如果没吃的,就喊妈妈做饭,暂时吃不了 65 | while (!hasFood) { 66 | try { 67 | lock.wait(); 68 | } catch (InterruptedException e) { 69 | throw new RuntimeException(e); 70 | } 71 | } 72 | // 否则就吃饭 73 | System.out.println(Thread.currentThread().getName() + "感谢老妈,恰饭,恰饭"); 74 | // 吃完之后,修改为false 75 | hasFood = false; 76 | // 通知其他线程吃饭 77 | lock.notifyAll(); 78 | } 79 | } 80 | } 81 | } 82 | 83 | -------------------------------------------------------------------------------- /day5/WaitNotifyAllTest4.java: -------------------------------------------------------------------------------- 1 | package day5; 2 | 3 | public class WaitNotifyAllTest4 { 4 | 5 | public static void main(String[] args) { 6 | // 创建饭菜对象 7 | KitChenRoom chenRoom = new KitChenRoom(); 8 | // 创建小明妈妈线程,做饭 9 | new Thread(() -> { 10 | for (int i = 0; i < 3; i++) { 11 | chenRoom.cook(); 12 | } 13 | },"小明妈妈线程:").start(); 14 | // 爸爸线程:做饭 15 | new Thread(() -> { 16 | for (int i = 0; i < 3; i++) { 17 | chenRoom.cook(); 18 | } 19 | },"小明爸爸线程:").start(); 20 | // 创建小明自己线程,吃饭 21 | new Thread(() -> { 22 | for (int i = 0; i < 3; i++) { 23 | chenRoom.eat(); 24 | } 25 | },"小明自己线程:").start(); 26 | // 大明线程:吃饭 27 | new Thread(() -> { 28 | for (int i = 0; i < 3; i++) { 29 | chenRoom.eat(); 30 | } 31 | },"大明哥哥线程:").start(); 32 | } 33 | 34 | public static class KitChenRoom { 35 | // 是否有吃的 36 | private boolean hasFood = false; 37 | // 设置同步锁,做饭和吃饭只能同时有一个在执行,不能边做边吃 38 | private final Object lock = new Object(); 39 | // 做饭 40 | public void cook() { 41 | // 加锁 42 | synchronized (lock) { 43 | // 如果有吃的,就不做饭 44 | while(hasFood) { 45 | // 还有吃的,先不做饭 46 | try { 47 | lock.wait(); 48 | } catch (InterruptedException e) { 49 | throw new RuntimeException(e); 50 | } 51 | } 52 | // 否则就做饭, 53 | System.out.println(Thread.currentThread().getName() + "没吃的了,给娃做饭!"); 54 | // 做好之后,修改为true 55 | hasFood = true; 56 | // 通知其他线程吃饭 57 | lock.notify(); 58 | } 59 | } 60 | 61 | // 吃饭 62 | public void eat() { 63 | synchronized (lock) { 64 | // 如果没吃的,就喊妈妈做饭,暂时吃不了 65 | while (!hasFood) { 66 | try { 67 | lock.wait(); 68 | } catch (InterruptedException e) { 69 | throw new RuntimeException(e); 70 | } 71 | } 72 | // 否则就吃饭 73 | System.out.println(Thread.currentThread().getName() + "感谢老妈,恰饭,恰饭"); 74 | // 吃完之后,修改为false 75 | hasFood = false; 76 | // 通知其他线程吃饭 77 | lock.notify(); 78 | } 79 | } 80 | } 81 | } 82 | 83 | -------------------------------------------------------------------------------- /day5/WaitNotifyAllTest5.java: -------------------------------------------------------------------------------- 1 | package day5; 2 | 3 | public class WaitNotifyAllTest5 { 4 | 5 | public static void main(String[] args) { 6 | // 创建饭菜对象 7 | KitChenRoom chenRoom = new KitChenRoom(); 8 | // 创建小明妈妈线程,做饭 9 | new Thread(() -> { 10 | for (int i = 0; i < 3; i++) { 11 | chenRoom.cook(); 12 | } 13 | },"小明妈妈线程:").start(); 14 | // 爸爸线程:做饭 15 | new Thread(() -> { 16 | for (int i = 0; i < 3; i++) { 17 | chenRoom.cook(); 18 | } 19 | },"小明爸爸线程:").start(); 20 | // 创建小明自己线程,吃饭 21 | new Thread(() -> { 22 | for (int i = 0; i < 3; i++) { 23 | chenRoom.eat(); 24 | } 25 | },"小明自己线程:").start(); 26 | // 大明线程:吃饭 27 | new Thread(() -> { 28 | for (int i = 0; i < 3; i++) { 29 | chenRoom.eat(); 30 | } 31 | },"大明哥哥线程:").start(); 32 | } 33 | 34 | public static class KitChenRoom { 35 | // 是否有吃的 36 | private boolean hasFood = false; 37 | // 设置同步锁,做饭和吃饭只能同时有一个在执行,不能边做边吃 38 | private final Object lock = new Object(); 39 | // 做饭 40 | public void cook() { 41 | // 加锁 42 | synchronized (lock) { 43 | // 如果有吃的,就不做饭 44 | while(hasFood) { 45 | // 还有吃的,先不做饭 46 | try { 47 | lock.wait(2000); 48 | } catch (InterruptedException e) { 49 | throw new RuntimeException(e); 50 | } 51 | } 52 | // 否则就做饭, 53 | System.out.println(Thread.currentThread().getName() + "没吃的了,给娃做饭!"); 54 | // 做好之后,修改为true 55 | hasFood = true; 56 | // 通知其他线程吃饭 57 | lock.notify(); 58 | } 59 | } 60 | 61 | // 吃饭 62 | public void eat() { 63 | synchronized (lock) { 64 | // 如果没吃的,就喊妈妈做饭,暂时吃不了 65 | while (!hasFood) { 66 | try { 67 | lock.wait(2000); 68 | } catch (InterruptedException e) { 69 | throw new RuntimeException(e); 70 | } 71 | } 72 | // 否则就吃饭 73 | System.out.println(Thread.currentThread().getName() + "感谢老妈,恰饭,恰饭"); 74 | // 吃完之后,修改为false 75 | hasFood = false; 76 | // 通知其他线程吃饭 77 | lock.notify(); 78 | } 79 | } 80 | } 81 | } 82 | 83 | -------------------------------------------------------------------------------- /day5/wait_question_image1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yangchong211/YCJavaBlog/5a758d927e1c8faf659690ab59ce842119d85042/day5/wait_question_image1.png -------------------------------------------------------------------------------- /day7/FloatTest.java: -------------------------------------------------------------------------------- 1 | package day7; 2 | 3 | public class FloatTest { 4 | 5 | public static void main(String[] args) { 6 | test1(); 7 | test2(); 8 | } 9 | 10 | private static void test1() { 11 | float a = 2.0000001F; 12 | float b = 2.0000001F; 13 | System.out.println(a == b); // 输出true 14 | System.out.println(0.1f + 0.2f == 0.3f); // 输出true 15 | System.out.println(0.1 + 0.2 == 0.3); // 输出false 16 | System.out.println(0.3f + 0.6f == 0.9f); // 输出false 17 | System.out.println(0.3 + 0.6 == 0.9); // 输出false 18 | System.out.println(0.6 + 0.6 == 1.2); // 输出true 19 | System.out.println(0.2 + 0.2 == 0.4); // 输出true 20 | 21 | //打印结果 22 | //true 23 | //true 24 | //false 25 | //false 26 | //false 27 | //true 28 | //true 29 | } 30 | 31 | private static void test2() { 32 | float f = 1.4f; 33 | double d = 1.4d; 34 | float f1 = 1.5f; 35 | double d1 = 1.5d; 36 | 37 | System.out.println(f); //1.4 38 | System.out.println((double)f); //1.399999976158142 39 | System.out.println(d); //1.4 40 | System.out.println(f - d); //-2.3841857821338408E-8 41 | System.out.println(f == d); //false 42 | 43 | System.out.println("--------"); 44 | System.out.println(f1); //1.5 45 | System.out.println((double) f1); //1.5 46 | System.out.println(d1); //1.5 47 | System.out.println(f1 - d1); //0.0 48 | System.out.println(f1 == d1); //true 49 | 50 | 51 | //1.4 52 | //1.399999976158142 53 | //1.4 54 | //-2.3841857821338408E-8 55 | //false 56 | //-------- 57 | //1.5 58 | //1.5 59 | //1.5 60 | //0.0 61 | //true 62 | } 63 | 64 | } 65 | 66 | -------------------------------------------------------------------------------- /day9/FloatTest.java: -------------------------------------------------------------------------------- 1 | package day9; 2 | 3 | public class FloatTest { 4 | 5 | public static void main(String[] args) { 6 | test1(); 7 | test2(); 8 | } 9 | 10 | private static void test1() { 11 | float a = 2.0000001F; 12 | float b = 2.0000001F; 13 | System.out.println(a == b); // 输出true 14 | System.out.println(0.1f + 0.2f == 0.3f); // 输出true 15 | System.out.println(0.1 + 0.2 == 0.3); // 输出false 16 | System.out.println(0.3f + 0.6f == 0.9f); // 输出false 17 | System.out.println(0.3 + 0.6 == 0.9); // 输出false 18 | System.out.println(0.6 + 0.6 == 1.2); // 输出true 19 | System.out.println(0.2 + 0.2 == 0.4); // 输出true 20 | 21 | //打印结果 22 | //true 23 | //true 24 | //false 25 | //false 26 | //false 27 | //true 28 | //true 29 | } 30 | 31 | private static void test2() { 32 | float f = 1.4f; 33 | double d = 1.4d; 34 | float f1 = 1.5f; 35 | double d1 = 1.5d; 36 | 37 | System.out.println(f); //1.4 38 | System.out.println((double)f); //1.399999976158142 39 | System.out.println(d); //1.4 40 | System.out.println(f - d); //-2.3841857821338408E-8 41 | System.out.println(f == d); //false 42 | 43 | System.out.println("--------"); 44 | System.out.println(f1); //1.5 45 | System.out.println((double) f1); //1.5 46 | System.out.println(d1); //1.5 47 | System.out.println(f1 - d1); //0.0 48 | System.out.println(f1 == d1); //true 49 | 50 | 51 | //1.4 52 | //1.399999976158142 53 | //1.4 54 | //-2.3841857821338408E-8 55 | //false 56 | //-------- 57 | //1.5 58 | //1.5 59 | //1.5 60 | //0.0 61 | //true 62 | } 63 | 64 | } 65 | 66 | -------------------------------------------------------------------------------- /project/day2/serial_port_image1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yangchong211/YCJavaBlog/5a758d927e1c8faf659690ab59ce842119d85042/project/day2/serial_port_image1.png -------------------------------------------------------------------------------- /project/day2/serial_port_image2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yangchong211/YCJavaBlog/5a758d927e1c8faf659690ab59ce842119d85042/project/day2/serial_port_image2.png -------------------------------------------------------------------------------- /project/day2/serial_port_image3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yangchong211/YCJavaBlog/5a758d927e1c8faf659690ab59ce842119d85042/project/day2/serial_port_image3.png -------------------------------------------------------------------------------- /project/day2/serial_port_image4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yangchong211/YCJavaBlog/5a758d927e1c8faf659690ab59ce842119d85042/project/day2/serial_port_image4.png -------------------------------------------------------------------------------- /project/day2/serial_port_image5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yangchong211/YCJavaBlog/5a758d927e1c8faf659690ab59ce842119d85042/project/day2/serial_port_image5.png --------------------------------------------------------------------------------