From d44d787d463e4158726bde01a014f1be0d544fec Mon Sep 17 00:00:00 2001 From: CSapprenticeWT <838167398@qq.com> Date: Sun, 11 Dec 2022 11:16:35 +0800 Subject: [PATCH 1/8] Change test --- objects/HelloDate.java | 14 ++++++++++---- operators/Assignment.java | 3 ++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/objects/HelloDate.java b/objects/HelloDate.java index b408b1f48..a325d8f67 100644 --- a/objects/HelloDate.java +++ b/objects/HelloDate.java @@ -5,8 +5,14 @@ import java.util.*; public class HelloDate { - public static void main(String[] args) { - System.out.println("Hello, it's: "); - System.out.println(new Date()); - } +// public static void main(String[] args) { +// System.out.println("Hello, it's: "); +// System.out.println(new Date()); +// } + public static void main(String[] args) { + System.out.println("------"); + System.out.println(new Date()); + } } + + diff --git a/operators/Assignment.java b/operators/Assignment.java index c4b9a793e..c8212653a 100644 --- a/operators/Assignment.java +++ b/operators/Assignment.java @@ -16,7 +16,8 @@ public static void main(String[] args) { t2.level = 47; System.out.println("1: t1.level: " + t1.level + ", t2.level: " + t2.level); - t1 = t2; + // t1 = t2; 引用 + t1.level = t2.level; //实际对象 System.out.println("2: t1.level: " + t1.level + ", t2.level: " + t2.level); t1.level = 27; From f26bf3f5beefb381c6c4ba929b0329e0bd287899 Mon Sep 17 00:00:00 2001 From: CSapprenticeWT <838167398@qq.com> Date: Tue, 13 Dec 2022 11:33:19 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- operators/DoubleEquivalence.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/operators/DoubleEquivalence.java b/operators/DoubleEquivalence.java index 5f06e25f5..f2457d20d 100644 --- a/operators/DoubleEquivalence.java +++ b/operators/DoubleEquivalence.java @@ -13,21 +13,33 @@ static void show(String desc, Double n1, Double n2) { public static void test(double x1, double x2) { // x1.equals(x2) // Won't compile System.out.printf("%e==%e %b%n", x1, x2, x1 == x2); + Double d1 = x1; Double d2 = x2; show("Automatic", d1, d2); + Double r1 = new Double(x1); Double r2 = new Double(x2); show("new Double()", r1, r2); + Double v1 = Double.valueOf(x1); Double v2 = Double.valueOf(x2); show("Double.valueOf()", v1, v2); + } public static void main(String[] args) { + + //比较0和最小的浮点数 test(0, Double.MIN_VALUE); + System.out.println("------------------------"); + + //最大值 和 (最大值 和 (最小值只差的一百万倍))比较 test(Double.MAX_VALUE, Double.MAX_VALUE - Double.MIN_VALUE * 1_000_000); + + System.out.println("------------------------"); + test(2.1, 3.5); } } /* Output: From e754d88618e294021152048453a28289d8ac7da2 Mon Sep 17 00:00:00 2001 From: CSapprenticeWT <838167398@qq.com> Date: Tue, 13 Dec 2022 11:42:30 +0800 Subject: [PATCH 3/8] =?UTF-8?q?=E6=B3=A8=E9=87=8A=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- operators/DoubleEquivalence.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/operators/DoubleEquivalence.java b/operators/DoubleEquivalence.java index f2457d20d..46313003a 100644 --- a/operators/DoubleEquivalence.java +++ b/operators/DoubleEquivalence.java @@ -34,12 +34,19 @@ public static void main(String[] args) { System.out.println("------------------------"); - //最大值 和 (最大值 和 (最小值只差的一百万倍))比较 + //最大值 和 (最大值 和 (最小值只差的一百万倍))比较 一个非常大的数值减去一个相对较小的数值, + //非常大的数值并不会发生显著变化。这个叫做 舍入误差 <\b> test(Double.MAX_VALUE, Double.MAX_VALUE - Double.MIN_VALUE * 1_000_000); System.out.println("------------------------"); test(2.1, 3.5); + + System.out.println("------------------------"); + System.out.println(Double.MIN_VALUE); //2^-1074 + System.out.println(Double.MAX_VALUE); + + } } /* Output: From e23aaf547a9bc4972de55d34bc5deb1196a99493 Mon Sep 17 00:00:00 2001 From: CSapprenticeWT <838167398@qq.com> Date: Tue, 13 Dec 2022 12:04:49 +0800 Subject: [PATCH 4/8] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- operators/Bool.java | 1 + 1 file changed, 1 insertion(+) diff --git a/operators/Bool.java b/operators/Bool.java index 42668315b..8e216d876 100644 --- a/operators/Bool.java +++ b/operators/Bool.java @@ -26,6 +26,7 @@ public static void main(String[] args) { + ((i < 10) && (j < 10)) ); System.out.println("(i < 10) || (j < 10) is " + ((i < 10) || (j < 10)) ); + //如果在应该使用字符串的地方使用了布尔值,布尔值会自动转换成合适的文本格式 } } /* Output: From 9e5b8601634e3e9640ed7c41e406e84395bda97c Mon Sep 17 00:00:00 2001 From: CSapprenticeWT <838167398@qq.com> Date: Tue, 13 Dec 2022 12:15:18 +0800 Subject: [PATCH 5/8] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- operators/DoubleEquivalence.java | 69 +------------------------------- 1 file changed, 1 insertion(+), 68 deletions(-) diff --git a/operators/DoubleEquivalence.java b/operators/DoubleEquivalence.java index 46313003a..0d3640990 100644 --- a/operators/DoubleEquivalence.java +++ b/operators/DoubleEquivalence.java @@ -1,68 +1 @@ -// operators/DoubleEquivalence.java -// (c)2021 MindView LLC: see Copyright.txt -// We make no guarantees that this code is fit for any purpose. -// Visit http://OnJava8.com for more book information. - -public class DoubleEquivalence { - static void show(String desc, Double n1, Double n2) { - System.out.println(desc + ":"); - System.out.printf( - "%e==%e %b %b%n", n1, n2, n1 == n2, n1.equals(n2)); - } - @SuppressWarnings("deprecation") - public static void test(double x1, double x2) { - // x1.equals(x2) // Won't compile - System.out.printf("%e==%e %b%n", x1, x2, x1 == x2); - - Double d1 = x1; - Double d2 = x2; - show("Automatic", d1, d2); - - Double r1 = new Double(x1); - Double r2 = new Double(x2); - show("new Double()", r1, r2); - - Double v1 = Double.valueOf(x1); - Double v2 = Double.valueOf(x2); - show("Double.valueOf()", v1, v2); - - } - public static void main(String[] args) { - - //比较0和最小的浮点数 - test(0, Double.MIN_VALUE); - - System.out.println("------------------------"); - - //最大值 和 (最大值 和 (最小值只差的一百万倍))比较 一个非常大的数值减去一个相对较小的数值, - //非常大的数值并不会发生显著变化。这个叫做 舍入误差 <\b> - test(Double.MAX_VALUE, - Double.MAX_VALUE - Double.MIN_VALUE * 1_000_000); - - System.out.println("------------------------"); - test(2.1, 3.5); - - System.out.println("------------------------"); - System.out.println(Double.MIN_VALUE); //2^-1074 - System.out.println(Double.MAX_VALUE); - - - } -} -/* Output: -0.000000e+00==4.900000e-324 false -Automatic: -0.000000e+00==4.900000e-324 false false -new Double(): -0.000000e+00==4.900000e-324 false false -Double.valueOf(): -0.000000e+00==4.900000e-324 false false ------------------------- -1.797693e+308==1.797693e+308 true -Automatic: -1.797693e+308==1.797693e+308 false true -new Double(): -1.797693e+308==1.797693e+308 false true -Double.valueOf(): -1.797693e+308==1.797693e+308 false true -*/ +// operators/DoubleEquivalence.java // (c)2021 MindView LLC: see Copyright.txt // We make no guarantees that this code is fit for any purpose. // Visit http://OnJava8.com for more book information. public class DoubleEquivalence { static void show(String desc, Double n1, Double n2) { System.out.println(desc + ":"); System.out.printf( "%e==%e %b %b%n", n1, n2, n1 == n2, n1.equals(n2)); } @SuppressWarnings("deprecation") public static void test(double x1, double x2) { // x1.equals(x2) // Won't compile System.out.printf("%e==%e %b%n", x1, x2, x1 == x2); Double d1 = x1; Double d2 = x2; show("Automatic", d1, d2); Double r1 = new Double(x1); Double r2 = new Double(x2); show("new Double()", r1, r2); Double v1 = Double.valueOf(x1); Double v2 = Double.valueOf(x2); show("Double.valueOf()", v1, v2); } public static void main(String[] args) { //比较0和最小的浮点数 test(0, Double.MIN_VALUE); System.out.println("------------------------"); //最大值 和 (最大值 和 (最小值只差的一百万倍))比较 一个非常大的数值减去一个相对较小的数值, //非常大的数值并不会发生显著变化。这个叫做 舍入误差 <\b> test(Double.MAX_VALUE, Double.MAX_VALUE - Double.MIN_VALUE * 1_000_000); System.out.println("------------------------"); test(2.1, 3.5); System.out.println("------------------------"); System.out.println(Double.MIN_VALUE); //2^-1074 System.out.println(Double.MAX_VALUE); } } /* Output: 0.000000e+00==4.900000e-324 false Automatic: 0.000000e+00==4.900000e-324 false false new Double(): 0.000000e+00==4.900000e-324 false false Double.valueOf(): 0.000000e+00==4.900000e-324 false false ------------------------ 1.797693e+308==1.797693e+308 true Automatic: 1.797693e+308==1.797693e+308 false true new Double(): 1.797693e+308==1.797693e+308 false true Double.valueOf(): 1.797693e+308==1.797693e+308 false true */ \ No newline at end of file From a8c825fdeefc4bd87f713d38a038ad32917fc859 Mon Sep 17 00:00:00 2001 From: CSapprenticeWT <838167398@qq.com> Date: Tue, 13 Dec 2022 12:26:47 +0800 Subject: [PATCH 6/8] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index b4feb13d5..94d293993 100644 --- a/build.gradle +++ b/build.gradle @@ -17,7 +17,7 @@ subprojects { apply from: "$rootProject.projectDir/gradle/jmh.gradle" // apply from: "$rootProject.projectDir/gradle/checkstyle.gradle" apply from: "$rootProject.projectDir/gradle/findbugs.gradle" - apply plugin: 'com.mindviewinc.tagging' + //apply plugin: 'com.mindviewinc.tagging' } apply from: 'gradle/subprojects.gradle' From 6632e603436684e4ab9713c935d9fa9f0f59ea33 Mon Sep 17 00:00:00 2001 From: CSapprenticeWT <838167398@qq.com> Date: Tue, 3 Jan 2023 16:13:29 +0800 Subject: [PATCH 7/8] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- operators/Overflow.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/operators/Overflow.java b/operators/Overflow.java index 68e494490..87c52d14b 100644 --- a/operators/Overflow.java +++ b/operators/Overflow.java @@ -8,7 +8,7 @@ public class Overflow { public static void main(String[] args) { int big = Integer.MAX_VALUE; System.out.println("big = " + big); - int bigger = big * 4; + int bigger = big * 4; // 数据不对 System.out.println("bigger = " + bigger); } } From 74790e627276aff7955340e76c8f357560f2c1fe Mon Sep 17 00:00:00 2001 From: CSapprenticeWT <838167398@qq.com> Date: Tue, 3 Jan 2023 16:20:49 +0800 Subject: [PATCH 8/8] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- operators/Overflow.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/operators/Overflow.java b/operators/Overflow.java index 87c52d14b..1a89a5561 100644 --- a/operators/Overflow.java +++ b/operators/Overflow.java @@ -8,7 +8,7 @@ public class Overflow { public static void main(String[] args) { int big = Integer.MAX_VALUE; System.out.println("big = " + big); - int bigger = big * 4; // 数据不对 + int bigger = big * 4; // 数据不对 不是2147483647*4 System.out.println("bigger = " + bigger); } }