diff --git a/object.dat b/object.dat new file mode 100644 index 0000000..5600a93 Binary files /dev/null and b/object.dat differ diff --git a/oosT.txt b/oosT.txt new file mode 100644 index 0000000..3375483 --- /dev/null +++ b/oosT.txt @@ -0,0 +1 @@ +客户端你好,我是你爹 \ No newline at end of file diff --git a/out/production/reviewJava/dataStructureImpl/LinkListDemo.class b/out/production/reviewJava/dataStructureImpl/LinkListDemo.class index 5dfb1b6..94fd2a2 100644 Binary files a/out/production/reviewJava/dataStructureImpl/LinkListDemo.class and b/out/production/reviewJava/dataStructureImpl/LinkListDemo.class differ diff --git a/out/production/reviewJava/fruit-config.properties b/out/production/reviewJava/fruit-config.properties new file mode 100644 index 0000000..47b5361 --- /dev/null +++ b/out/production/reviewJava/fruit-config.properties @@ -0,0 +1,3 @@ +AppleName=thinkingInJava.learning.reflection.exer2.Apple +BananaName=thinkingInJava.learning.reflection.exer2.Banana +OrangeName=thinkingInJava.learning.reflection.exer2.Orange \ No newline at end of file diff --git a/out/production/reviewJava/infoClassLoaderTest.properties b/out/production/reviewJava/infoClassLoaderTest.properties new file mode 100644 index 0000000..71f4897 --- /dev/null +++ b/out/production/reviewJava/infoClassLoaderTest.properties @@ -0,0 +1,2 @@ +host=127.0.0.1 +port=8989 \ No newline at end of file diff --git a/out/production/reviewJava/thinkingInJava/learning/ToBinaryDemo.class b/out/production/reviewJava/thinkingInJava/learning/ToBinaryDemo.class index e3f7503..b7def61 100644 Binary files a/out/production/reviewJava/thinkingInJava/learning/ToBinaryDemo.class and b/out/production/reviewJava/thinkingInJava/learning/ToBinaryDemo.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/api/compare/ComparableTest.class b/out/production/reviewJava/thinkingInJava/learning/api/compare/ComparableTest.class new file mode 100644 index 0000000..2ef2699 Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/api/compare/ComparableTest.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/api/compare/ComparatorTest$1.class b/out/production/reviewJava/thinkingInJava/learning/api/compare/ComparatorTest$1.class new file mode 100644 index 0000000..6122cf6 Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/api/compare/ComparatorTest$1.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/api/compare/ComparatorTest$2.class b/out/production/reviewJava/thinkingInJava/learning/api/compare/ComparatorTest$2.class new file mode 100644 index 0000000..551ac35 Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/api/compare/ComparatorTest$2.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/api/compare/ComparatorTest.class b/out/production/reviewJava/thinkingInJava/learning/api/compare/ComparatorTest.class new file mode 100644 index 0000000..6489de0 Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/api/compare/ComparatorTest.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/api/compare/Product.class b/out/production/reviewJava/thinkingInJava/learning/api/compare/Product.class new file mode 100644 index 0000000..81952d6 Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/api/compare/Product.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/api/date/TestT.class b/out/production/reviewJava/thinkingInJava/learning/api/date/TestT.class new file mode 100644 index 0000000..bdafbcb Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/api/date/TestT.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/api/date/before8/DataTimeTest.class b/out/production/reviewJava/thinkingInJava/learning/api/date/before8/DataTimeTest.class new file mode 100644 index 0000000..eceaba4 Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/api/date/before8/DataTimeTest.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/api/date/exer/Exer1.class b/out/production/reviewJava/thinkingInJava/learning/api/date/exer/Exer1.class new file mode 100644 index 0000000..5ba30f4 Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/api/date/exer/Exer1.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/api/date/jdk8/DateimeTest.class b/out/production/reviewJava/thinkingInJava/learning/api/date/jdk8/DateimeTest.class new file mode 100644 index 0000000..a859c6c Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/api/date/jdk8/DateimeTest.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/api/stringMore/InterviewTest1.class b/out/production/reviewJava/thinkingInJava/learning/api/stringMore/InterviewTest1.class new file mode 100644 index 0000000..d19c522 Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/api/stringMore/InterviewTest1.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/api/stringMore/InterviewTest2.class b/out/production/reviewJava/thinkingInJava/learning/api/stringMore/InterviewTest2.class new file mode 100644 index 0000000..cbde83e Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/api/stringMore/InterviewTest2.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/api/stringMore/InterviewTest3.class b/out/production/reviewJava/thinkingInJava/learning/api/stringMore/InterviewTest3.class new file mode 100644 index 0000000..a64941c Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/api/stringMore/InterviewTest3.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/api/stringMore/InterviewTest4.class b/out/production/reviewJava/thinkingInJava/learning/api/stringMore/InterviewTest4.class new file mode 100644 index 0000000..018bf4b Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/api/stringMore/InterviewTest4.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/api/stringMore/StringMoreTest.class b/out/production/reviewJava/thinkingInJava/learning/api/stringMore/StringMoreTest.class index 2ad632f..0bcecca 100644 Binary files a/out/production/reviewJava/thinkingInJava/learning/api/stringMore/StringMoreTest.class and b/out/production/reviewJava/thinkingInJava/learning/api/stringMore/StringMoreTest.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Collection/List/ArrayListTest.class b/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Collection/List/ArrayListTest.class new file mode 100644 index 0000000..2fd3f1b Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Collection/List/ArrayListTest.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Collection/List/Person.class b/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Collection/List/Person.class new file mode 100644 index 0000000..3ac7a9b Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Collection/List/Person.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Collection/List/exer1/Exer1.class b/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Collection/List/exer1/Exer1.class new file mode 100644 index 0000000..cb0c9ec Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Collection/List/exer1/Exer1.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Collection/List/exer1/ListTest.class b/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Collection/List/exer1/ListTest.class new file mode 100644 index 0000000..9cd58fe Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Collection/List/exer1/ListTest.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Collection/List/exer1/StudentPerson.class b/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Collection/List/exer1/StudentPerson.class new file mode 100644 index 0000000..8648407 Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Collection/List/exer1/StudentPerson.class differ diff --git "a/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Collection/List/exer1/\347\273\203\344\271\240\351\242\230\347\233\256.png" "b/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Collection/List/exer1/\347\273\203\344\271\240\351\242\230\347\233\256.png" new file mode 100644 index 0000000..45fb231 Binary files /dev/null and "b/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Collection/List/exer1/\347\273\203\344\271\240\351\242\230\347\233\256.png" differ diff --git a/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Collection/List/exer2/Exer2.class b/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Collection/List/exer2/Exer2.class new file mode 100644 index 0000000..b3e376b Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Collection/List/exer2/Exer2.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Collection/List/exer2/img.png b/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Collection/List/exer2/img.png new file mode 100644 index 0000000..51d5375 Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Collection/List/exer2/img.png differ diff --git a/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Collection/Set/SetTest$1.class b/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Collection/Set/SetTest$1.class new file mode 100644 index 0000000..1d4bd2c Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Collection/Set/SetTest$1.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Collection/Set/SetTest.class b/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Collection/Set/SetTest.class new file mode 100644 index 0000000..8a5abd3 Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Collection/Set/SetTest.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Collection/Set/exer1/Exer1.class b/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Collection/Set/exer1/Exer1.class new file mode 100644 index 0000000..14d75d2 Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Collection/Set/exer1/Exer1.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Collection/Set/exer1/img.png b/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Collection/Set/exer1/img.png new file mode 100644 index 0000000..fd79177 Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Collection/Set/exer1/img.png differ diff --git a/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Collection/Set/exer2/Exer2.class b/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Collection/Set/exer2/Exer2.class new file mode 100644 index 0000000..b38d9b3 Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Collection/Set/exer2/Exer2.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Collection/Set/exer2/img.png b/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Collection/Set/exer2/img.png new file mode 100644 index 0000000..adcc30a Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Collection/Set/exer2/img.png differ diff --git a/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/CollectionTest.class b/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/CollectionTest.class new file mode 100644 index 0000000..fabebf4 Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/CollectionTest.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Map/MapTest$1.class b/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Map/MapTest$1.class new file mode 100644 index 0000000..fd21595 Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Map/MapTest$1.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Map/MapTest.class b/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Map/MapTest.class new file mode 100644 index 0000000..c1c9cae Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Map/MapTest.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Map/PropertiesTest.class b/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Map/PropertiesTest.class new file mode 100644 index 0000000..ee8addf Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Map/PropertiesTest.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Map/exer1/Exer1.class b/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Map/exer1/Exer1.class new file mode 100644 index 0000000..df6123f Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Map/exer1/Exer1.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Map/exer1/img.png b/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Map/exer1/img.png new file mode 100644 index 0000000..bc96db5 Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Map/exer1/img.png differ diff --git a/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Map/exer2/CityEnum.class b/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Map/exer2/CityEnum.class new file mode 100644 index 0000000..6414747 Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Map/exer2/CityEnum.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Map/exer2/CityMap.class b/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Map/exer2/CityMap.class new file mode 100644 index 0000000..f9e0fbc Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Map/exer2/CityMap.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Map/exer2/Exer2_Two_class_move.class b/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Map/exer2/Exer2_Two_class_move.class new file mode 100644 index 0000000..70e1818 Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Map/exer2/Exer2_Two_class_move.class differ diff --git "a/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Map/exer2/\344\272\214\347\272\247\350\201\224\345\212\250.png" "b/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Map/exer2/\344\272\214\347\272\247\350\201\224\345\212\250.png" new file mode 100644 index 0000000..a5fe184 Binary files /dev/null and "b/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Map/exer2/\344\272\214\347\272\247\350\201\224\345\212\250.png" differ diff --git "a/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Map/exer2/\346\225\210\346\236\234.png" "b/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Map/exer2/\346\225\210\346\236\234.png" new file mode 100644 index 0000000..7449cbc Binary files /dev/null and "b/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Map/exer2/\346\225\210\346\236\234.png" differ diff --git a/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Map/info-config.properties b/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Map/info-config.properties new file mode 100644 index 0000000..998b4e1 --- /dev/null +++ b/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/Map/info-config.properties @@ -0,0 +1,2 @@ +name=Tom Cruse +psw=qwe123 \ No newline at end of file diff --git a/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/SourceCodeTest.class b/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/SourceCodeTest.class new file mode 100644 index 0000000..453046d Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/SourceCodeTest.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/collectionsUtil/CollectionUtilTest$1.class b/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/collectionsUtil/CollectionUtilTest$1.class new file mode 100644 index 0000000..88bea42 Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/collectionsUtil/CollectionUtilTest$1.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/collectionsUtil/CollectionUtilTest.class b/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/collectionsUtil/CollectionUtilTest.class new file mode 100644 index 0000000..c4e4145 Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/collectionsUtil/CollectionUtilTest.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/collectionsUtil/exer1_xi_pai/Exer1.class b/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/collectionsUtil/exer1_xi_pai/Exer1.class new file mode 100644 index 0000000..ebdc191 Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/collectionsUtil/exer1_xi_pai/Exer1.class differ diff --git "a/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/collectionsUtil/exer1_xi_pai/\346\264\227\347\211\214.png" "b/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/collectionsUtil/exer1_xi_pai/\346\264\227\347\211\214.png" new file mode 100644 index 0000000..0f62048 Binary files /dev/null and "b/out/production/reviewJava/thinkingInJava/learning/collectionsFrame/collectionsUtil/exer1_xi_pai/\346\264\227\347\211\214.png" differ diff --git a/out/production/reviewJava/thinkingInJava/learning/dataStructure/DataStructureTest.class b/out/production/reviewJava/thinkingInJava/learning/dataStructure/DataStructureTest.class new file mode 100644 index 0000000..53bd666 Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/dataStructure/DataStructureTest.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/dataStructure/queue/NodeQueue.class b/out/production/reviewJava/thinkingInJava/learning/dataStructure/queue/NodeQueue.class new file mode 100644 index 0000000..09a7de3 Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/dataStructure/queue/NodeQueue.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/dataStructure/stack/NodeStack.class b/out/production/reviewJava/thinkingInJava/learning/dataStructure/stack/NodeStack.class new file mode 100644 index 0000000..9602cb4 Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/dataStructure/stack/NodeStack.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/fileAndIOStream/FileAndIOTest.class b/out/production/reviewJava/thinkingInJava/learning/fileAndIOStream/FileAndIOTest.class new file mode 100644 index 0000000..e162d99 Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/fileAndIOStream/FileAndIOTest.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/fileAndIOStream/exer1/Exer1$1.class b/out/production/reviewJava/thinkingInJava/learning/fileAndIOStream/exer1/Exer1$1.class new file mode 100644 index 0000000..2a7df14 Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/fileAndIOStream/exer1/Exer1$1.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/fileAndIOStream/exer1/Exer1.class b/out/production/reviewJava/thinkingInJava/learning/fileAndIOStream/exer1/Exer1.class new file mode 100644 index 0000000..90e9b92 Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/fileAndIOStream/exer1/Exer1.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/fileAndIOStream/exer1/img.png b/out/production/reviewJava/thinkingInJava/learning/fileAndIOStream/exer1/img.png new file mode 100644 index 0000000..85be8fa Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/fileAndIOStream/exer1/img.png differ diff --git a/out/production/reviewJava/thinkingInJava/learning/fileAndIOStream/fas.txt b/out/production/reviewJava/thinkingInJava/learning/fileAndIOStream/fas.txt new file mode 100644 index 0000000..e69de29 diff --git a/out/production/reviewJava/thinkingInJava/learning/fileAndIOStream/fat.txt b/out/production/reviewJava/thinkingInJava/learning/fileAndIOStream/fat.txt new file mode 100644 index 0000000..e69de29 diff --git a/out/production/reviewJava/thinkingInJava/learning/fileAndIOStream/fileStream/BufferedStreamTest.class b/out/production/reviewJava/thinkingInJava/learning/fileAndIOStream/fileStream/BufferedStreamTest.class new file mode 100644 index 0000000..815acde Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/fileAndIOStream/fileStream/BufferedStreamTest.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/fileAndIOStream/fileStream/FileStreamTest.class b/out/production/reviewJava/thinkingInJava/learning/fileAndIOStream/fileStream/FileStreamTest.class new file mode 100644 index 0000000..34efceb Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/fileAndIOStream/fileStream/FileStreamTest.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/fileAndIOStream/fileStream/ObjectStreamTest.class b/out/production/reviewJava/thinkingInJava/learning/fileAndIOStream/fileStream/ObjectStreamTest.class new file mode 100644 index 0000000..054687a Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/fileAndIOStream/fileStream/ObjectStreamTest.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/fileAndIOStream/fileStream/img.png b/out/production/reviewJava/thinkingInJava/learning/fileAndIOStream/fileStream/img.png new file mode 100644 index 0000000..9f45f54 Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/fileAndIOStream/fileStream/img.png differ diff --git a/out/production/reviewJava/thinkingInJava/learning/fileAndIOStream/fileStream/img2.png b/out/production/reviewJava/thinkingInJava/learning/fileAndIOStream/fileStream/img2.png new file mode 100644 index 0000000..9f45f54 Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/fileAndIOStream/fileStream/img2.png differ diff --git a/out/production/reviewJava/thinkingInJava/learning/fileAndIOStream/fileStream/img3.png b/out/production/reviewJava/thinkingInJava/learning/fileAndIOStream/fileStream/img3.png new file mode 100644 index 0000000..9f45f54 Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/fileAndIOStream/fileStream/img3.png differ diff --git a/out/production/reviewJava/thinkingInJava/learning/fileAndIOStream/fileStream/log.txt b/out/production/reviewJava/thinkingInJava/learning/fileAndIOStream/fileStream/log.txt new file mode 100644 index 0000000..2a9dda7 --- /dev/null +++ b/out/production/reviewJava/thinkingInJava/learning/fileAndIOStream/fileStream/log.txt @@ -0,0 +1,19 @@ +Hello esteemed interviewer, + I'm delighted to be here today for this interview opportunity. My name is weiwenxu, +and I am currently a graduate student at Xi'an University of Architecture and Technology, +specializing in Electronic Information. + Throughout my academic journey, I've had the privilege of participating in the +"Huawei Cup" Graduate Mathematical Modeling Competition twice, earning both a +national third prize and a second prize. Additionally, I've been actively engaged +in academic research, having authored a paper on multi-task graph convolutional +neural networks, which I'm preparing to submit to relevant journals. + Beyond my academic achievements, I have a strong interest in backend development. +I've self-taught myself various technologies such as Java, Spring Boot, MySQL, and +MyBatis, and I've applied these skills to successfully develop a backend business logic +for a mall project named GgM. + I am fully aware of the rare opportunity it would be to join your esteemed industry. +If given the chance to be a part of your team, I am committed to cherishing this opportunity +and dedicating myself to continuous learning and growth, contributing my best efforts to the +company's success. + Thank you for considering me for this opportunity. I eagerly look forward to the possibility +of becoming a valuable member of your company. Thank you! \ No newline at end of file diff --git a/out/production/reviewJava/thinkingInJava/learning/fileAndIOStream/fileStream/log2.txt b/out/production/reviewJava/thinkingInJava/learning/fileAndIOStream/fileStream/log2.txt new file mode 100644 index 0000000..2a9dda7 --- /dev/null +++ b/out/production/reviewJava/thinkingInJava/learning/fileAndIOStream/fileStream/log2.txt @@ -0,0 +1,19 @@ +Hello esteemed interviewer, + I'm delighted to be here today for this interview opportunity. My name is weiwenxu, +and I am currently a graduate student at Xi'an University of Architecture and Technology, +specializing in Electronic Information. + Throughout my academic journey, I've had the privilege of participating in the +"Huawei Cup" Graduate Mathematical Modeling Competition twice, earning both a +national third prize and a second prize. Additionally, I've been actively engaged +in academic research, having authored a paper on multi-task graph convolutional +neural networks, which I'm preparing to submit to relevant journals. + Beyond my academic achievements, I have a strong interest in backend development. +I've self-taught myself various technologies such as Java, Spring Boot, MySQL, and +MyBatis, and I've applied these skills to successfully develop a backend business logic +for a mall project named GgM. + I am fully aware of the rare opportunity it would be to join your esteemed industry. +If given the chance to be a part of your team, I am committed to cherishing this opportunity +and dedicating myself to continuous learning and growth, contributing my best efforts to the +company's success. + Thank you for considering me for this opportunity. I eagerly look forward to the possibility +of becoming a valuable member of your company. Thank you! \ No newline at end of file diff --git a/out/production/reviewJava/thinkingInJava/learning/fileAndIOStream/fileStream/log3.txt b/out/production/reviewJava/thinkingInJava/learning/fileAndIOStream/fileStream/log3.txt new file mode 100644 index 0000000..030ba9b --- /dev/null +++ b/out/production/reviewJava/thinkingInJava/learning/fileAndIOStream/fileStream/log3.txt @@ -0,0 +1,18 @@ +Hello esteemed interviewer, + I'm delighted to be here today for this interview opportunity. My name is weiwenxu, +and I am currently a graduate student at Xi'an University of Architecture and Technology, +majoring in Electronic Information. + Throughout my academic journey, I've had the privilege of participating in the +"Huawei Cup" Graduate Mathematical Modeling Competition twice, earning both a +national third prize and a second prize respectivly. Additionally, I've been actively engaged +in academic research, having authored a paper on multi-task graph convolutional +neural networks, which I'm preparing to submit to relevant journals. + Beyond my academic achievements, I have a strong interest in backend development. +I've self-taught myself various technologies such as Java, Spring Boot, MySQL, and +MyBatis, and I've applied these skills to successfully develop a backend business logic +for a mall project named GgM. + I am fully aware of the rare opportunity to join you.If given the chance to be a part of your team, +I am committed to cherishing this opportunity and dedicating myself to continuous learning and growth, +contributing my best efforts to the company's success. + Thank you for considering me for this opportunity. I am eagerly looking forward to have the chance to join you. +Thank you! \ No newline at end of file diff --git a/out/production/reviewJava/thinkingInJava/learning/fileAndIOStream/fileStream/oosT.txt b/out/production/reviewJava/thinkingInJava/learning/fileAndIOStream/fileStream/oosT.txt new file mode 100644 index 0000000..f12e592 Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/fileAndIOStream/fileStream/oosT.txt differ diff --git a/out/production/reviewJava/thinkingInJava/learning/fileAndIOStream/fileStream/teff.txt b/out/production/reviewJava/thinkingInJava/learning/fileAndIOStream/fileStream/teff.txt new file mode 100644 index 0000000..e69de29 diff --git a/out/production/reviewJava/thinkingInJava/learning/fileAndIOStream/objectIo/ObjectIOTest.class b/out/production/reviewJava/thinkingInJava/learning/fileAndIOStream/objectIo/ObjectIOTest.class new file mode 100644 index 0000000..46f6df0 Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/fileAndIOStream/objectIo/ObjectIOTest.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/fileAndIOStream/objectIo/PeopleT.class b/out/production/reviewJava/thinkingInJava/learning/fileAndIOStream/objectIo/PeopleT.class new file mode 100644 index 0000000..be43241 Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/fileAndIOStream/objectIo/PeopleT.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/fileAndIOStream/tess.txt b/out/production/reviewJava/thinkingInJava/learning/fileAndIOStream/tess.txt new file mode 100644 index 0000000..91b0331 --- /dev/null +++ b/out/production/reviewJava/thinkingInJava/learning/fileAndIOStream/tess.txt @@ -0,0 +1,6 @@ +hello +jessy +billy +jerry +merry +kk \ No newline at end of file diff --git a/out/production/reviewJava/thinkingInJava/learning/genericity/selfDefine/GenericityTest2.class b/out/production/reviewJava/thinkingInJava/learning/genericity/selfDefine/GenericityTest2.class new file mode 100644 index 0000000..747f4b1 Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/genericity/selfDefine/GenericityTest2.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/genericity/use/GenericityTest.class b/out/production/reviewJava/thinkingInJava/learning/genericity/use/GenericityTest.class new file mode 100644 index 0000000..0d68599 Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/genericity/use/GenericityTest.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/genericity/use/exer1/Exer$1.class b/out/production/reviewJava/thinkingInJava/learning/genericity/use/exer1/Exer$1.class new file mode 100644 index 0000000..934dc2d Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/genericity/use/exer1/Exer$1.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/genericity/use/exer1/Exer.class b/out/production/reviewJava/thinkingInJava/learning/genericity/use/exer1/Exer.class new file mode 100644 index 0000000..9d71976 Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/genericity/use/exer1/Exer.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/genericity/use/exer1/img.png b/out/production/reviewJava/thinkingInJava/learning/genericity/use/exer1/img.png new file mode 100644 index 0000000..cca29ae Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/genericity/use/exer1/img.png differ diff --git a/out/production/reviewJava/thinkingInJava/learning/internet/InternetTest.class b/out/production/reviewJava/thinkingInJava/learning/internet/InternetTest.class new file mode 100644 index 0000000..7bc8354 Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/internet/InternetTest.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/internet/chat/ChatClient.class b/out/production/reviewJava/thinkingInJava/learning/internet/chat/ChatClient.class new file mode 100644 index 0000000..a62e3f7 Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/internet/chat/ChatClient.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/internet/chat/ChatServer.class b/out/production/reviewJava/thinkingInJava/learning/internet/chat/ChatServer.class new file mode 100644 index 0000000..6cac09d Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/internet/chat/ChatServer.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/internet/exer1/Exer1.class b/out/production/reviewJava/thinkingInJava/learning/internet/exer1/Exer1.class new file mode 100644 index 0000000..c7b97c9 Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/internet/exer1/Exer1.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/internet/exer1/img.png b/out/production/reviewJava/thinkingInJava/learning/internet/exer1/img.png new file mode 100644 index 0000000..4137c1f Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/internet/exer1/img.png differ diff --git a/out/production/reviewJava/thinkingInJava/learning/internet/exer2/Exer2.class b/out/production/reviewJava/thinkingInJava/learning/internet/exer2/Exer2.class new file mode 100644 index 0000000..6878717 Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/internet/exer2/Exer2.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/internet/exer2/img_1.png b/out/production/reviewJava/thinkingInJava/learning/internet/exer2/img_1.png new file mode 100644 index 0000000..3192ddc Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/internet/exer2/img_1.png differ diff --git a/out/production/reviewJava/thinkingInJava/learning/internet/exer3/Exer3.class b/out/production/reviewJava/thinkingInJava/learning/internet/exer3/Exer3.class new file mode 100644 index 0000000..6ef5d6a Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/internet/exer3/Exer3.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/internet/exer3/img.png b/out/production/reviewJava/thinkingInJava/learning/internet/exer3/img.png new file mode 100644 index 0000000..b74949a Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/internet/exer3/img.png differ diff --git a/out/production/reviewJava/thinkingInJava/learning/internet/exer3/test.png b/out/production/reviewJava/thinkingInJava/learning/internet/exer3/test.png new file mode 100644 index 0000000..61d5076 Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/internet/exer3/test.png differ diff --git a/out/production/reviewJava/thinkingInJava/learning/internet/exer3/test2_copy.png b/out/production/reviewJava/thinkingInJava/learning/internet/exer3/test2_copy.png new file mode 100644 index 0000000..61d5076 Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/internet/exer3/test2_copy.png differ diff --git a/out/production/reviewJava/thinkingInJava/learning/internet/exer3/test_copy.png b/out/production/reviewJava/thinkingInJava/learning/internet/exer3/test_copy.png new file mode 100644 index 0000000..61d5076 Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/internet/exer3/test_copy.png differ diff --git "a/out/production/reviewJava/thinkingInJava/learning/internet/exer3/test\350\260\242\350\260\242_copy.png" "b/out/production/reviewJava/thinkingInJava/learning/internet/exer3/test\350\260\242\350\260\242_copy.png" new file mode 100644 index 0000000..61d5076 Binary files /dev/null and "b/out/production/reviewJava/thinkingInJava/learning/internet/exer3/test\350\260\242\350\260\242_copy.png" differ diff --git a/out/production/reviewJava/thinkingInJava/learning/reflection/PersonPP.class b/out/production/reviewJava/thinkingInJava/learning/reflection/PersonPP.class new file mode 100644 index 0000000..7b7b9b8 Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/reflection/PersonPP.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/reflection/PersonSu.class b/out/production/reviewJava/thinkingInJava/learning/reflection/PersonSu.class new file mode 100644 index 0000000..d75c91b Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/reflection/PersonSu.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/reflection/ReflectionTest.class b/out/production/reviewJava/thinkingInJava/learning/reflection/ReflectionTest.class new file mode 100644 index 0000000..7e3a882 Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/reflection/ReflectionTest.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/reflection/class_/ClassTest.class b/out/production/reviewJava/thinkingInJava/learning/reflection/class_/ClassTest.class new file mode 100644 index 0000000..1fb8d93 Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/reflection/class_/ClassTest.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/reflection/class_/UserCustomedFieldMethodETC.class b/out/production/reviewJava/thinkingInJava/learning/reflection/class_/UserCustomedFieldMethodETC.class new file mode 100644 index 0000000..0d329b9 Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/reflection/class_/UserCustomedFieldMethodETC.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/reflection/exer1/Exer1.class b/out/production/reviewJava/thinkingInJava/learning/reflection/exer1/Exer1.class new file mode 100644 index 0000000..c67d1e0 Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/reflection/exer1/Exer1.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/reflection/exer1/info.properties b/out/production/reviewJava/thinkingInJava/learning/reflection/exer1/info.properties new file mode 100644 index 0000000..71f4897 --- /dev/null +++ b/out/production/reviewJava/thinkingInJava/learning/reflection/exer1/info.properties @@ -0,0 +1,2 @@ +host=127.0.0.1 +port=8989 \ No newline at end of file diff --git a/out/production/reviewJava/thinkingInJava/learning/reflection/exer2/Apple.class b/out/production/reviewJava/thinkingInJava/learning/reflection/exer2/Apple.class new file mode 100644 index 0000000..31aeb0b Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/reflection/exer2/Apple.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/reflection/exer2/Banana.class b/out/production/reviewJava/thinkingInJava/learning/reflection/exer2/Banana.class new file mode 100644 index 0000000..1b72ee1 Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/reflection/exer2/Banana.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/reflection/exer2/Exer2.class b/out/production/reviewJava/thinkingInJava/learning/reflection/exer2/Exer2.class new file mode 100644 index 0000000..7aa1ed7 Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/reflection/exer2/Exer2.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/reflection/exer2/Fruit.class b/out/production/reviewJava/thinkingInJava/learning/reflection/exer2/Fruit.class new file mode 100644 index 0000000..ceb5e04 Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/reflection/exer2/Fruit.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/reflection/exer2/Juicer.class b/out/production/reviewJava/thinkingInJava/learning/reflection/exer2/Juicer.class new file mode 100644 index 0000000..88a613e Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/reflection/exer2/Juicer.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/reflection/exer2/Orange.class b/out/production/reviewJava/thinkingInJava/learning/reflection/exer2/Orange.class new file mode 100644 index 0000000..2ee1398 Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/reflection/exer2/Orange.class differ diff --git a/out/production/reviewJava/thinkingInJava/learning/reflection/exer2/img.png b/out/production/reviewJava/thinkingInJava/learning/reflection/exer2/img.png new file mode 100644 index 0000000..6f4959c Binary files /dev/null and b/out/production/reviewJava/thinkingInJava/learning/reflection/exer2/img.png differ diff --git a/src/dataStructureImpl/LinkListDemo.java b/src/dataStructureImpl/LinkListDemo.java index b6b2d8f..9e3244f 100644 --- a/src/dataStructureImpl/LinkListDemo.java +++ b/src/dataStructureImpl/LinkListDemo.java @@ -1,5 +1,6 @@ package dataStructureImpl; +import java.util.Comparator; import java.util.Scanner; public class LinkListDemo { @@ -23,6 +24,7 @@ public static void main(String[] args) { System.out.print("[ " + p.data + " | (" + p.next + ") ]" + "-->"); p = p.next; } + System.out.println(linkListHead.length); // System.out.println(linkListHead+"[--]"+linkListHead.data + "--" + linkListHead.next); // System.out.println(linkListHead.next+"[--]"+linkListHead.next.data + "--" + linkListHead.next.next); diff --git a/src/fruit-config.properties b/src/fruit-config.properties new file mode 100644 index 0000000..47b5361 --- /dev/null +++ b/src/fruit-config.properties @@ -0,0 +1,3 @@ +AppleName=thinkingInJava.learning.reflection.exer2.Apple +BananaName=thinkingInJava.learning.reflection.exer2.Banana +OrangeName=thinkingInJava.learning.reflection.exer2.Orange \ No newline at end of file diff --git a/src/infoClassLoaderTest.properties b/src/infoClassLoaderTest.properties new file mode 100644 index 0000000..71f4897 --- /dev/null +++ b/src/infoClassLoaderTest.properties @@ -0,0 +1,2 @@ +host=127.0.0.1 +port=8989 \ No newline at end of file diff --git a/src/thinkingInJava/learning/ToBinaryDemo.java b/src/thinkingInJava/learning/ToBinaryDemo.java index 7e1a432..d716200 100644 --- a/src/thinkingInJava/learning/ToBinaryDemo.java +++ b/src/thinkingInJava/learning/ToBinaryDemo.java @@ -19,10 +19,11 @@ public static void main(String[] args) { System.out.println("======================"); - int b = 1; + int b = 10; System.out.println(Integer.toBinaryString(b)); - System.out.println(Integer.toBinaryString(b>>=10)); - System.out.println(Integer.toBinaryString(b>>>=10)); + System.out.println(Integer.toBinaryString(b>>=3)); + System.out.println(Integer.toBinaryString(b<<=4)); + System.out.println(Integer.toHexString(17)); } diff --git a/src/thinkingInJava/learning/api/compare/ComparableTest.java b/src/thinkingInJava/learning/api/compare/ComparableTest.java new file mode 100644 index 0000000..1adbe7a --- /dev/null +++ b/src/thinkingInJava/learning/api/compare/ComparableTest.java @@ -0,0 +1,37 @@ +package thinkingInJava.learning.api.compare; + +import org.junit.Test; + +import java.util.Arrays; + +public class ComparableTest { + @Test + public void test1() { + String array[] = new String[]{"Tom", "Jack", "Tony", "Hallen"}; + + Arrays.sort(array); + + for (String a : array + ) { + System.out.println(a); + } + } + + @Test + public void test2() { + String array[] = new String[]{"Tom", "Jack", "Tony", "Hallen"}; + Product product[] = new Product[5]; + product[0] = new Product("BMW", 50); + product[1] = new Product("Benz", 70); + product[2] = new Product("Audi", 40); + product[3] = new Product("Das Auto", 20); + product[4] = new Product("BYD", 35); + + Arrays.sort(product); + + for (Product p : + product) { + System.out.println(p.toString()); + } + } +} diff --git a/src/thinkingInJava/learning/api/compare/ComparatorTest.java b/src/thinkingInJava/learning/api/compare/ComparatorTest.java new file mode 100644 index 0000000..5ee4c64 --- /dev/null +++ b/src/thinkingInJava/learning/api/compare/ComparatorTest.java @@ -0,0 +1,60 @@ +package thinkingInJava.learning.api.compare; + +import org.junit.Test; + +import java.util.Arrays; +import java.util.Comparator; + +public class ComparatorTest { + @Test + public void test1() { + Product products[] = new Product[5]; + products[0] = new Product("BMW", 50); + products[1] = new Product("Benz", 70); + products[2] = new Product("Audi", 40); + products[3] = new Product("Das Auto", 20); + products[4] = new Product("BYD", 35); + + //创建一个实现了Comparator接口的实现类 + Comparator comparator = new Comparator() { + @Override + public int compare(Object o1, Object o2) { + if (o1 == o2) { + return 0; + } + if (o1 instanceof Product && o2 instanceof Product) { + Product p1 = (Product) o1; + Product p2 = (Product) o2; + + return Double.compare(p1.getPrice(), p2.getPrice()); + } + throw new RuntimeException("类型不匹配"); + } + }; + + Comparator comparator1 = new Comparator() { + @Override + public int compare(Object o1, Object o2) { + if (o1 == o2) { + return 0; + } + if (o1 instanceof Product && o2 instanceof Product) { + Product p1 = (Product) o1; + Product p2 = (Product) o2; + + return p1.getName().compareTo(p2.getName()); + } + throw new RuntimeException("类型不匹配"); + } + }; + + + Arrays.sort(products,comparator1); + + for (Product p : + products) { + System.out.println(p.toString()); + } + + } +} diff --git a/src/thinkingInJava/learning/api/compare/Product.java b/src/thinkingInJava/learning/api/compare/Product.java new file mode 100644 index 0000000..e8c328d --- /dev/null +++ b/src/thinkingInJava/learning/api/compare/Product.java @@ -0,0 +1,53 @@ +package thinkingInJava.learning.api.compare; + +public class Product implements Comparable{ + private String name; + private Integer price; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Integer getPrice() { + return price; + } + + public void setPrice(Integer price) { + this.price = price; + } + + public Product(String name, Integer price) { + this.name = name; + this.price = price; + } + + @Override + public String toString() { + return "Product{" + + "name='" + name + '\'' + + ", price=" + price + + '}'; + } + + //按照价格排序 + //如果返回值是正数,当前对象大 + //如果返回值是负数,当前对象小 + //如果返回值是0,一样大 + @Override + public int compareTo(Product o) { + if (o == this) { + return 0; + } + + if (o instanceof Product) { + Product p = (Product) o; + return Double.compare(this.price, p.price); + } + throw new RuntimeException("类型不匹配"); + + } +} diff --git a/src/thinkingInJava/learning/api/date/TestT.java b/src/thinkingInJava/learning/api/date/TestT.java new file mode 100644 index 0000000..e98edeb --- /dev/null +++ b/src/thinkingInJava/learning/api/date/TestT.java @@ -0,0 +1,19 @@ +package thinkingInJava.learning.api.date; + +import org.junit.Test; + +import java.text.SimpleDateFormat; +import java.util.Date; + +public class TestT { + @Test + public void test1() { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy MM dd | HH:mm:ss"); + + Date date = new Date(); + + String s = simpleDateFormat.format(date); + + System.out.println(s); + } +} diff --git a/src/thinkingInJava/learning/api/date/before8/DataTimeTest.java b/src/thinkingInJava/learning/api/date/before8/DataTimeTest.java new file mode 100644 index 0000000..17fbe92 --- /dev/null +++ b/src/thinkingInJava/learning/api/date/before8/DataTimeTest.java @@ -0,0 +1,66 @@ +package thinkingInJava.learning.api.date.before8; + +import org.junit.Test; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; + +public class DataTimeTest { + /* + Data类的使用 + |--java.util.Data + > 两个构造器的使用 Date(),Date(long timetemp) + > 两个方法的使用 1.toString() 2 getTime() + |----java.sql.Data 对应于数据库中 + */ + + @Test + public void test1() throws ParseException { + Date date1 = new Date(); //创建一个基于当前系统时间的Data类 + System.out.println(date1.toString()); + System.out.println(date1.getTime()); //对应毫秒数 + + SimpleDateFormat format = new SimpleDateFormat(); + String format1 = format.format(date1); + System.out.println(format1); + //解析 时间字符串 + System.out.println(format.parse("23-11-22 下午4:46")); + + Date date2 = new Date(1800552833223L); //指定时间戳的Date实例 + System.out.println(date2.toString()); + } + + @Test + public void test2() { + java.sql.Date date1 = new java.sql.Date(2340552833223L); //创建一个基于当前系统时间的Data类 + System.out.println(date1.toString()); + System.out.println(date1.getTime()); + } + + @Test + public void test3() throws ParseException { + //SimpleDateFormat 自定义格式 + //1.获取当前系统时间 + Date date = new Date(); + //2.传入自定义格式的参数,调用SimpleDateFormat(String pattern)构造器,得到SimpleDateFormat实例 + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM-dd,EEE | yyyy HH:mm:ss Z"); + //3.通过实例调用format方法,并传入当前系统时间对象 + String format = simpleDateFormat.format(date); + System.out.println(format); + + + //解析 + Date parse = simpleDateFormat.parse("11-22,星期三 | 2023 16:50:03 +0800"); + System.out.println(parse); + } + + @Test + public void calendarTest() { + Calendar instance = Calendar.getInstance(); + System.out.println(instance.get(Calendar.DAY_OF_WEEK)); + System.out.println(instance.get(Calendar.DAY_OF_YEAR)); + System.out.println(instance.get(Calendar.DAY_OF_MONTH)); + } +} \ No newline at end of file diff --git a/src/thinkingInJava/learning/api/date/exer/Exer1.java b/src/thinkingInJava/learning/api/date/exer/Exer1.java new file mode 100644 index 0000000..a793852 --- /dev/null +++ b/src/thinkingInJava/learning/api/date/exer/Exer1.java @@ -0,0 +1,24 @@ +package thinkingInJava.learning.api.date.exer; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Scanner; + +public class Exer1 { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd"); + System.out.print("请输入年月日(1998/05/18)"); + + String getDate = sc.next(); + try { + Date parse = simpleDateFormat.parse(getDate); + long time = parse.getTime(); + java.sql.Date date = new java.sql.Date(time); + System.out.println(date); + } catch (ParseException e) { + e.printStackTrace(); + } + } +} diff --git a/src/thinkingInJava/learning/api/date/jdk8/DateimeTest.java b/src/thinkingInJava/learning/api/date/jdk8/DateimeTest.java new file mode 100644 index 0000000..310f462 --- /dev/null +++ b/src/thinkingInJava/learning/api/date/jdk8/DateimeTest.java @@ -0,0 +1,27 @@ +package thinkingInJava.learning.api.date.jdk8; + +import org.junit.Test; + +import java.time.*; + +public class DateimeTest { + @Test + public void localDateTest() { + LocalDate localDate = LocalDate.now(); + LocalTime localTime = LocalTime.now(); + LocalDateTime localDateTime = LocalDateTime.now(); + + System.out.println(localDate); + System.out.println(localTime); + System.out.println(localDateTime); + } + + @Test + public void instantTest() { + Instant instant = Instant.now(); + System.out.println(instant); + + OffsetDateTime dong8 = instant.atOffset(ZoneOffset.ofHours(8));//东八区,与生成的有八小时时差 + System.out.println(dong8); + } +} diff --git a/src/thinkingInJava/learning/api/string/StringMethodTest1.java b/src/thinkingInJava/learning/api/string/StringMethodTest1.java index 2e94e0c..2e72b52 100644 --- a/src/thinkingInJava/learning/api/string/StringMethodTest1.java +++ b/src/thinkingInJava/learning/api/string/StringMethodTest1.java @@ -11,7 +11,7 @@ public class StringMethodTest1 { (1) boolean isEmpty():判断是否为空 (2) int length():返回字符串长度 (3) String concat(xx):拼接字符串 - (4) boolean equals(Object obj):比较字符串是否相等,区分大小写 + (4) boolean equals(Object obj):比较字 符串是否相等,区分大小写 (5) boolean equalsIgnoreCase(Object obj):比较字符串是否相等,不区分大小写 (6) int compareTo(String other):比较字符串大小,区分大小写,按照Unicode编码值比较 (7) int compareToIgnoreCase(String other):比较字符串大小,不区分大小写 @@ -126,7 +126,7 @@ public void test5() { @Test public void test6() { String s = "hello"; - System.out.println(s.replace("l", "c")); //he::o + System.out.println(s.replace("l", "c")); //hecco System.out.println(s.replace("llo", "xxs")); //hexxs } @Test diff --git a/src/thinkingInJava/learning/api/stringMore/InterviewTest1.java b/src/thinkingInJava/learning/api/stringMore/InterviewTest1.java new file mode 100644 index 0000000..243f7df --- /dev/null +++ b/src/thinkingInJava/learning/api/stringMore/InterviewTest1.java @@ -0,0 +1,18 @@ +package thinkingInJava.learning.api.stringMore; + +public class InterviewTest1 { + public static void main(String[] args) { + StringBuffer a = new StringBuffer("A"); + StringBuffer b = new StringBuffer("B"); + + operate(a, b); + + System.out.println(a +","+ b); //ABx,B + } + + static void operate(StringBuffer x, StringBuffer y) { + x.append(y); //AB + y = x; //AB + y.append('x'); //ABx + } +} diff --git a/src/thinkingInJava/learning/api/stringMore/InterviewTest2.java b/src/thinkingInJava/learning/api/stringMore/InterviewTest2.java new file mode 100644 index 0000000..47c6ce3 --- /dev/null +++ b/src/thinkingInJava/learning/api/stringMore/InterviewTest2.java @@ -0,0 +1,22 @@ +package thinkingInJava.learning.api.stringMore; + +public class InterviewTest2 { + public static void stringReplace(String text) { + text.replace('j', 'i'); + } + + public static void bufferReplace(StringBuffer text) { + text.append("C"); + text = new StringBuffer("Hello"); + text.append("World!"); + } + + public static void main(String[] args) { + String textString = new String("java"); + StringBuffer textBuffer = new StringBuffer("java"); + stringReplace(textString); + bufferReplace(textBuffer); + + System.out.println(textString + textBuffer); //javaCHelloWorld! x (javajavaC) + } +} diff --git a/src/thinkingInJava/learning/api/stringMore/InterviewTest3.java b/src/thinkingInJava/learning/api/stringMore/InterviewTest3.java new file mode 100644 index 0000000..796b63f --- /dev/null +++ b/src/thinkingInJava/learning/api/stringMore/InterviewTest3.java @@ -0,0 +1,16 @@ +package thinkingInJava.learning.api.stringMore; + +public class InterviewTest3 { + private static void change(String s, StringBuffer stringBuffer) { + s = "aaaa"; + stringBuffer.setLength(0); + stringBuffer.append("aaaa"); + } + + public static void main(String[] args) { + String s = "bbbb"; + StringBuffer stringBuffer = new StringBuffer("bbbb"); + change(s, stringBuffer); + System.out.println(s+stringBuffer); // bbbbaaaa + } +} diff --git a/src/thinkingInJava/learning/api/stringMore/InterviewTest4.java b/src/thinkingInJava/learning/api/stringMore/InterviewTest4.java new file mode 100644 index 0000000..f188a18 --- /dev/null +++ b/src/thinkingInJava/learning/api/stringMore/InterviewTest4.java @@ -0,0 +1,16 @@ +package thinkingInJava.learning.api.stringMore; + +public class InterviewTest4 { + public static void main(String[] args) { + String str = null; + StringBuffer sb = new StringBuffer(); + sb.append(str); + + System.out.println(sb.length()); //4 + + System.out.println(sb); //"null" + + StringBuffer sb1 = new StringBuffer(str); + System.out.println(sb1); //NullPointerException 因为 底层调用 str.length() 来设置StringBuffer的长度 + } +} diff --git a/src/thinkingInJava/learning/api/stringMore/StringMoreTest.java b/src/thinkingInJava/learning/api/stringMore/StringMoreTest.java index df88bc8..b46fd60 100644 --- a/src/thinkingInJava/learning/api/stringMore/StringMoreTest.java +++ b/src/thinkingInJava/learning/api/stringMore/StringMoreTest.java @@ -52,9 +52,32 @@ public void stringBufferOrBuilderMethodTest1() { } + /**其他API + * int indexOf(String str): 在当前字符序列中查询str第一次出现的位置 + * int indexOf(String str, int fromIndex): 在当前字符序列 [fromIndex,最后]中查询str第一次出现的下标 + * int lastIndexOf(String str): 在当前字符序列中查询str最后一次出现的下标 + * int lastIndexOf(String str,int fromIndex): 在当前字符序列[fromIndex,最后]中查询str最后一次出现的下标 + * String substring(int start): 截取当前字符序列 [start,最后] + * String substring(int start, int end): 截取当前字符序列 [start, end) + * String toString(): 返回此序列中数据的字符串表示形式 + * void setLength(int newLength): 设置当前字符序列长度为newLength + */ @Test public void stringBufferTest2() { + StringBuffer sb1 = new StringBuffer("abc123edf456"); + + System.out.println(sb1.indexOf("123")); + System.out.println(sb1.indexOf("123",1)); + + System.out.println(sb1.substring(3)); + System.out.println(sb1.substring(3,5)); + + System.out.println(sb1.length() + " : str=" + sb1); //12 : str=abc123edf456 + sb1.setLength(5); + System.out.println(sb1.length() + " : str=" + sb1); //5 : str=abc12 + sb1.append("hahaha"); + System.out.println(sb1); //abc12hahaha } } diff --git a/src/thinkingInJava/learning/collectionsFrame/Collection/List/ArrayListTest.java b/src/thinkingInJava/learning/collectionsFrame/Collection/List/ArrayListTest.java new file mode 100644 index 0000000..4121c49 --- /dev/null +++ b/src/thinkingInJava/learning/collectionsFrame/Collection/List/ArrayListTest.java @@ -0,0 +1,74 @@ +package thinkingInJava.learning.collectionsFrame.Collection.List; + +import org.junit.Test; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; + +public class ArrayListTest { + @Test + public void test1() { + /** + * (1) add(Object obj): 添加元素对象到当前集合中 + * (2) addAll(Collection other): 将other集合中的所有元素添加到当前集合中 + */ + Collection coll = new ArrayList(); + + coll.add("AA"); + coll.add(123);// 自动装箱 + coll.add("尚硅谷");// 自动拆箱 + coll.add(new Object()); + coll.add(new Person("Wwx", 30)); + + System.out.println(coll); + + Iterator iterator = coll.iterator(); + while (iterator.hasNext()) { + System.out.println(iterator.next()); + } + + + Collection coll2 = new ArrayList(); + coll2.add("haha"); // 自动装箱 + coll2.addAll(coll);// 集合coll2添加集合coll中的所有元素 + + System.out.println(coll2); + } + + @Test + public void test2() { + Collection coll = new ArrayList(); + + coll.add("AA"); + coll.add(128);// 自动装箱 + coll.add("尚硅谷");// 自动拆箱 + coll.add(new Object()); + coll.add(new Person("Wwx", 30)); + + System.out.println(coll.isEmpty()); + System.out.println(coll.size()); + System.out.println(coll.contains("AA"));//true + System.out.println(coll.contains(new Person("Wwx", 30)));//false 因为new Person是引用类型,是新new的对象,所以不相等 + System.out.println(coll.contains(128));//true + } + + @Test + public void test3() { + Collection coll = new ArrayList(); + + coll.add("AA"); + coll.add(128);// 自动装箱 + coll.add("尚硅谷");// 自动拆箱 + coll.add(new Object()); + coll.add(new Person("Wwx", 30)); + + ArrayList objects = new ArrayList<>(); + objects.add("AA"); + objects.add(128); + objects.add(456); + objects.add(new Person("Wwx", 30)); + + System.out.println(coll.retainAll(objects)); + } +} diff --git a/src/thinkingInJava/learning/collectionsFrame/Collection/List/Person.java b/src/thinkingInJava/learning/collectionsFrame/Collection/List/Person.java new file mode 100644 index 0000000..dce7b6b --- /dev/null +++ b/src/thinkingInJava/learning/collectionsFrame/Collection/List/Person.java @@ -0,0 +1,49 @@ +package thinkingInJava.learning.collectionsFrame.Collection.List; + +public class Person implements Comparable { + private String name; + private int age; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getAge() { + return age; + } + + public void setAge(int age) { + this.age = age; + } + + public Person(String name, int age) { + this.name = name; + this.age = age; + } + + @Override + public String toString() { + return "Person{" + + "name='" + name + '\'' + + ", age=" + age + + '}'; + } + + + //比较器,按照年龄排序,从小到大 + @Override + public int compareTo(Object o) { + if (this == o) { + return 0; + } + if (o instanceof Person) { + Person p = (Person) o; + return this.age - p.age; + } + throw new RuntimeException("类型不匹配"); + } +} diff --git a/src/thinkingInJava/learning/collectionsFrame/Collection/List/exer1/Exer1.java b/src/thinkingInJava/learning/collectionsFrame/Collection/List/exer1/Exer1.java new file mode 100644 index 0000000..95af687 --- /dev/null +++ b/src/thinkingInJava/learning/collectionsFrame/Collection/List/exer1/Exer1.java @@ -0,0 +1,35 @@ +package thinkingInJava.learning.collectionsFrame.Collection.List.exer1; + +import org.junit.Test; + +import java.util.ArrayList; +import java.util.Objects; +import java.util.Scanner; + +public class Exer1 { + public static void main(String[] args) { + ArrayList studentPeople = new ArrayList<>(); + Scanner sc = new Scanner(System.in); + int flag = 1; + System.out.println("请输入学生信息"); + + while (flag == 1) { + System.out.print("请输入姓名:"); + String name = sc.next(); + if (name != null) { + System.out.print("请输入年龄:"); + Integer age = sc.nextInt(); + studentPeople.add(new StudentPerson(name, age)); + + } + System.out.println("1:继续录入,0:结束录入"); + flag = sc.nextInt(); + } + + for (Object student : studentPeople) { + System.out.println(student.toString()); + } + + sc.close(); + } +} diff --git a/src/thinkingInJava/learning/collectionsFrame/Collection/List/exer1/ListTest.java b/src/thinkingInJava/learning/collectionsFrame/Collection/List/exer1/ListTest.java new file mode 100644 index 0000000..a4e296f --- /dev/null +++ b/src/thinkingInJava/learning/collectionsFrame/Collection/List/exer1/ListTest.java @@ -0,0 +1,46 @@ +package thinkingInJava.learning.collectionsFrame.Collection.List.exer1; + +import org.junit.Test; +import thinkingInJava.learning.collectionsFrame.Collection.List.Person; + +import java.util.*; + +public class ListTest { + @Test + public void arrayList() { + List list = new ArrayList(); + + list.add("AA"); + list.add(123); + list.add("BB"); + list.add(new Person("tom", 23)); + + System.out.println(list.toString()); + + } + + @Test + public void LinkedList() { + List list = new LinkedList(); + + list.add("AA"); + list.add(123); + list.add("BB"); + list.add(new Person("tom", 23)); + + System.out.println(list.toString()); + + } + + @Test + public void vector() { + List list = new Vector(); + list.add("AA"); + list.add(123); + list.add("BB"); + list.add(new Person("tom", 23)); + + System.out.println(list.toString()); + + } +} diff --git a/src/thinkingInJava/learning/collectionsFrame/Collection/List/exer1/StudentPerson.java b/src/thinkingInJava/learning/collectionsFrame/Collection/List/exer1/StudentPerson.java new file mode 100644 index 0000000..f535e8e --- /dev/null +++ b/src/thinkingInJava/learning/collectionsFrame/Collection/List/exer1/StudentPerson.java @@ -0,0 +1,53 @@ +package thinkingInJava.learning.collectionsFrame.Collection.List.exer1; + +import java.util.Objects; + +public class StudentPerson { + private String name; + private Integer age; + + public StudentPerson() { + } + + public StudentPerson(String name, Integer age) { + this.name = name; + this.age = age; + } + + @Override + public String toString() { + return "StudentPerson{" + + "name='" + name + '\'' + + ", age=" + age + + '}'; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + StudentPerson that = (StudentPerson) o; + return Objects.equals(name, that.name) && Objects.equals(age, that.age); + } + + @Override + public int hashCode() { + return Objects.hash(name, age); + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Integer getAge() { + return age; + } + + public void setAge(Integer age) { + this.age = age; + } +} diff --git "a/src/thinkingInJava/learning/collectionsFrame/Collection/List/exer1/\347\273\203\344\271\240\351\242\230\347\233\256.png" "b/src/thinkingInJava/learning/collectionsFrame/Collection/List/exer1/\347\273\203\344\271\240\351\242\230\347\233\256.png" new file mode 100644 index 0000000..45fb231 Binary files /dev/null and "b/src/thinkingInJava/learning/collectionsFrame/Collection/List/exer1/\347\273\203\344\271\240\351\242\230\347\233\256.png" differ diff --git a/src/thinkingInJava/learning/collectionsFrame/Collection/List/exer2/Exer2.java b/src/thinkingInJava/learning/collectionsFrame/Collection/List/exer2/Exer2.java new file mode 100644 index 0000000..4e8652a --- /dev/null +++ b/src/thinkingInJava/learning/collectionsFrame/Collection/List/exer2/Exer2.java @@ -0,0 +1,35 @@ +package thinkingInJava.learning.collectionsFrame.Collection.List.exer2; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.Random; + +public class Exer2 { + + public static int listTest(Collection list, String s) { + int count = 0; + for (Object o : list) { + if (o.equals(s)) { + count++; + } + } + return count; + } + + public static void main(String[] args) { + ArrayList arrayList = new ArrayList(); + for (int i = 0; i < 30; i++) { + int v = (int) (Math.random() * (122 - 97 + 1)) + 97; + arrayList.add((char) v +""); + } + + System.out.println(arrayList.toString()); + + System.out.println("a出现了:" + listTest(arrayList, "a") + "次数"); + System.out.println("b出现了:" + listTest(arrayList, "b") + "次数"); + System.out.println("c出现了:" + listTest(arrayList, "c") + "次数"); + System.out.println("x出现了:" + listTest(arrayList, "x") + "次数"); + + } +} diff --git a/src/thinkingInJava/learning/collectionsFrame/Collection/List/exer2/img.png b/src/thinkingInJava/learning/collectionsFrame/Collection/List/exer2/img.png new file mode 100644 index 0000000..51d5375 Binary files /dev/null and b/src/thinkingInJava/learning/collectionsFrame/Collection/List/exer2/img.png differ diff --git a/src/thinkingInJava/learning/collectionsFrame/Collection/Set/SetTest.java b/src/thinkingInJava/learning/collectionsFrame/Collection/Set/SetTest.java new file mode 100644 index 0000000..ec1987b --- /dev/null +++ b/src/thinkingInJava/learning/collectionsFrame/Collection/Set/SetTest.java @@ -0,0 +1,91 @@ +package thinkingInJava.learning.collectionsFrame.Collection.Set; + +import org.junit.Test; +import thinkingInJava.learning.collectionsFrame.Collection.List.Person; + +import java.util.*; + +public class SetTest { + @Test + public void hashSet() { + Set set = new HashSet(); + set.addAll(Collections.singleton(0x128)); + set.add("AA"); + set.add("BB"); + set.add(new Person("asd", 123)); + set.add("aa"); + set.add("aa"); + System.out.println(set.toString()); + } + + @Test + public void treeSet() { + Set set = new TreeSet(); + set.add("BB"); + set.add("aa"); + set.add("AA"); +// set.add(13); //java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer + + Iterator iterator = set.iterator(); + while (iterator.hasNext()) { + System.out.println(iterator.next()); + } + + } + + + /** + * 自然排序 + */ + @Test + public void treeSet1() { + Set set = new TreeSet(); + + set.add(new Person("tom", 15)); + set.add(new Person("jack", 18)); + set.add(new Person("rose", 16)); + set.add(new Person("jerry", 33)); + + Iterator iterator = set.iterator(); + while (iterator.hasNext()) { + System.out.println(iterator.next()); + } + } + + + /** + * 定制排序 + */ + @Test + public void treeSet2() { + //定制排序的规则 + Comparator objectComparator = new Comparator() { + @Override + public int compare(Object o1, Object o2) { + if (o1 instanceof Person && o2 instanceof Person) { + Person p1 = (Person) o1; + Person p2 = (Person) o2; + + if (p1.getName().compareTo(p2.getName()) == 0) { + return p1.getAge() - p2.getAge(); + } else { + return p1.getName().compareTo(p2.getName()); + } + } + throw new RuntimeException("类型不匹配"); + } + }; + + Set set = new TreeSet(objectComparator);//传入定制规则 + + set.add(new Person("tom", 15)); + set.add(new Person("jack", 18)); + set.add(new Person("rose", 16)); + set.add(new Person("jerry", 33)); + + Iterator iterator = set.iterator(); + while (iterator.hasNext()) { + System.out.println(iterator.next()); + } + } +} diff --git a/src/thinkingInJava/learning/collectionsFrame/Collection/Set/exer1/Exer1.java b/src/thinkingInJava/learning/collectionsFrame/Collection/Set/exer1/Exer1.java new file mode 100644 index 0000000..2a400e9 --- /dev/null +++ b/src/thinkingInJava/learning/collectionsFrame/Collection/Set/exer1/Exer1.java @@ -0,0 +1,44 @@ +package thinkingInJava.learning.collectionsFrame.Collection.Set.exer1; + +import java.util.ArrayList; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; + +public class Exer1 { + + public static List duplicateList(List list) { + //方式1 +// LinkedHashSet objects = new LinkedHashSet<>(); +// for (int i = 0; i < list.size(); i++) { +// objects.add(list.get(i)); +// } +// ArrayList objects1 = new ArrayList<>(); +// objects1.addAll(objects); +// return objects1; + + //方式2 + LinkedHashSet linkedHashSet = new LinkedHashSet<>(list); + ArrayList arrayList = new ArrayList<>(linkedHashSet); + return arrayList; + } + + public static void initialList(List list) { + list.add(1); + list.add(2); + list.add(2); + list.add(4); + list.add(3); + list.add(4); + list.add(6); + list.add(3); + } + public static void main(String[] args) { + List list = new ArrayList(); + initialList(list); + + List newList = duplicateList(list); + + System.out.println(newList.toString()); + } +} diff --git a/src/thinkingInJava/learning/collectionsFrame/Collection/Set/exer1/img.png b/src/thinkingInJava/learning/collectionsFrame/Collection/Set/exer1/img.png new file mode 100644 index 0000000..fd79177 Binary files /dev/null and b/src/thinkingInJava/learning/collectionsFrame/Collection/Set/exer1/img.png differ diff --git a/src/thinkingInJava/learning/collectionsFrame/Collection/Set/exer2/Exer2.java b/src/thinkingInJava/learning/collectionsFrame/Collection/Set/exer2/Exer2.java new file mode 100644 index 0000000..b103978 --- /dev/null +++ b/src/thinkingInJava/learning/collectionsFrame/Collection/Set/exer2/Exer2.java @@ -0,0 +1,22 @@ +package thinkingInJava.learning.collectionsFrame.Collection.Set.exer2; + +import java.util.HashSet; +import java.util.Set; + +public class Exer2 { + + public static int getRandom(int from, int to) { + return (int) (Math.random() * (to - from + 1)) + from; //生成 [from,to) 的随机数 + } + + public static void main(String[] args) { + HashSet set = new HashSet(); + + while (set.size() < 20) { + set.add(getRandom(1, 20)); + } + + System.out.println(set.toString()); + + } +} diff --git a/src/thinkingInJava/learning/collectionsFrame/Collection/Set/exer2/img.png b/src/thinkingInJava/learning/collectionsFrame/Collection/Set/exer2/img.png new file mode 100644 index 0000000..adcc30a Binary files /dev/null and b/src/thinkingInJava/learning/collectionsFrame/Collection/Set/exer2/img.png differ diff --git a/src/thinkingInJava/learning/collectionsFrame/CollectionTest.java b/src/thinkingInJava/learning/collectionsFrame/CollectionTest.java new file mode 100644 index 0000000..2866877 --- /dev/null +++ b/src/thinkingInJava/learning/collectionsFrame/CollectionTest.java @@ -0,0 +1,27 @@ +package thinkingInJava.learning.collectionsFrame; + +import org.junit.Test; +import thinkingInJava.learning.collectionsFrame.Collection.List.ArrayListTest; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; + +public class CollectionTest { + @Test + public void test() { + Collection coll = new ArrayList(); + coll.add("abd"); + coll.add("bad"); + coll.add("ber"); + coll.add("ccd"); + coll.add("ffr"); + + Iterator iterator = coll.iterator(); + + while (iterator.hasNext()) { + System.out.println(iterator.next()); + System.out.println(iterator.getClass().getName()); + } + } +} diff --git a/src/thinkingInJava/learning/collectionsFrame/Map/MapTest.java b/src/thinkingInJava/learning/collectionsFrame/Map/MapTest.java new file mode 100644 index 0000000..3e06d91 --- /dev/null +++ b/src/thinkingInJava/learning/collectionsFrame/Map/MapTest.java @@ -0,0 +1,140 @@ +package thinkingInJava.learning.collectionsFrame.Map; + +import org.junit.Test; + +import java.text.SimpleDateFormat; +import java.util.*; + +public class MapTest { + @Test + public void mapTest() { + Map m = new HashMap<>(); + m.put(null, null); + System.out.println(m); + // {null=null} + } + + @Test + public void mapTest2() { + Map m = new Hashtable<>(); + m.put(null, null); + System.out.println(m); + // NullPointerException + } + + @Test + public void mapTest3() { + Map m = new HashMap<>(); + m.put("AA", "BB"); + m.put("jack", "rose"); + m.put("name", "titanic"); + m.put("date", new SimpleDateFormat("yyyy:MM-dd").format(new Date())); + + System.out.println(m); + } + + @Test + public void mapTest4() { + Map m = new LinkedHashMap();//无序存放,但由于双向链表的存在,查询看起来是有序的 + m.put("AA", "BB"); + m.put("jack", "rose"); + m.put("name", "titanic"); + m.put("date", new SimpleDateFormat("yyyy:MM-dd").format(new Date())); + + System.out.println(m); + + + //遍历 + Set keySet = m.keySet(); + Iterator iterator = keySet.iterator(); + while (iterator.hasNext()) { + Object k = iterator.next(); + System.out.println("(" + k + ")--(" + m.get(k) + ")"); + } + + Set set = m.entrySet(); + Iterator iterator1 = set.iterator(); + while (iterator1.hasNext()) { + System.out.println(iterator1.next()); + } + } + + @Test + public void mapMthodTest() { + Map m = new HashMap<>(); + //增 + m.put("qwe", 123); + m.put("invoker", 2); + m.put("dagger", 2200); + m.put("AA", 56); + m.put("Das Vagen", 140335); + m.put("date", new SimpleDateFormat("yyyy/MM/dd").format(new Date())); + + System.out.println(m); + + //size + System.out.println(m.size()); + //修改 + m.put("qwe", 777); + System.out.println(m); + //删除 + Object qwe = m.remove("qwe"); + System.out.println(qwe); + System.out.println(m); + //查询 + System.out.println(m.get("date")); + + + //遍历key + Set set = m.keySet(); + System.out.print("keySet :"); + for (Object k : set) { + System.out.print(k + ", "); + } + System.out.println(); + + //遍历value + Collection values = m.values(); + Iterator iterator = values.iterator(); + System.out.print("values :"); + while (iterator.hasNext()) { + System.out.print(iterator.next() + ", "); + } + System.out.println(); + + //遍历entry + Set set1 = m.entrySet(); + for (Object o : set1) { + Map.Entry entry = (Map.Entry) o; + System.out.println(o); + System.out.println(entry.getKey() + "----->" + entry.getValue()); + } + + } + + + @Test + public void treeMapTest() { + //定制排序 + Comparator objectComparator = new Comparator() { + @Override + public int compare(Object o1, Object o2) { + if (o1 instanceof String && o2 instanceof String) { + String oo1 = (String) o1; + String oo2 = (String) o2; + + return oo1.compareTo(oo2); + } + throw new RuntimeException("类型不匹配"); + } + }; + TreeMap m = new TreeMap<>(objectComparator); + m.put("qwe", 123); + m.put("invoker", 2); + m.put("dagger", 2200); + m.put("AA", 56); + m.put("Das Vagen", 140335); + m.put("date", 20240307); + System.out.println(m); + } +} diff --git a/src/thinkingInJava/learning/collectionsFrame/Map/PropertiesTest.java b/src/thinkingInJava/learning/collectionsFrame/Map/PropertiesTest.java new file mode 100644 index 0000000..28ae7fa --- /dev/null +++ b/src/thinkingInJava/learning/collectionsFrame/Map/PropertiesTest.java @@ -0,0 +1,29 @@ +package thinkingInJava.learning.collectionsFrame.Map; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.Properties; + +public class PropertiesTest { + public static void main(String[] args) { + File file = new File("D:\\DevProj\\Java\\reviewJava\\src\\thinkingInJava\\learning\\collectionsFrame\\Map\\info-config.properties"); + try { + FileInputStream fileInputStream = new FileInputStream(file); + + Properties properties = new Properties(); + + properties.load(fileInputStream); + + String name = properties.getProperty("name"); + String psw = properties.getProperty("psw"); + + System.out.println(name + "--" + psw); + fileInputStream.close(); + } catch (IOException e) { + e.printStackTrace(); + } + + } +} diff --git a/src/thinkingInJava/learning/collectionsFrame/Map/exer1/Exer1.java b/src/thinkingInJava/learning/collectionsFrame/Map/exer1/Exer1.java new file mode 100644 index 0000000..7cd8b72 --- /dev/null +++ b/src/thinkingInJava/learning/collectionsFrame/Map/exer1/Exer1.java @@ -0,0 +1,38 @@ +package thinkingInJava.learning.collectionsFrame.Map.exer1; + +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Scanner; +import java.util.Set; + +public class Exer1 { + public static void main(String[] args) { + LinkedHashMap linkedHashMap = new LinkedHashMap<>(); + System.out.println("请保存数据"); + Scanner scanner = new Scanner(System.in); + boolean flag = true; + while (flag) { + System.out.println("0 退出程序,1 继续保存,2 查询歌单:"); + switch (scanner.nextInt()) { + case 0: + flag = false; + break; + case 1: + System.out.print("输入歌手名:"); + String name = scanner.next(); + System.out.print("请输入歌曲:"); + String song = scanner.next(); + linkedHashMap.put(name, song); + continue; + case 2: + Set> entries = linkedHashMap.entrySet(); + for (Object o : entries) { + System.out.println(o); + } + continue; + default: + break; + } + } + } +} diff --git a/src/thinkingInJava/learning/collectionsFrame/Map/exer1/img.png b/src/thinkingInJava/learning/collectionsFrame/Map/exer1/img.png new file mode 100644 index 0000000..bc96db5 Binary files /dev/null and b/src/thinkingInJava/learning/collectionsFrame/Map/exer1/img.png differ diff --git a/src/thinkingInJava/learning/collectionsFrame/Map/exer2/CityEnum.java b/src/thinkingInJava/learning/collectionsFrame/Map/exer2/CityEnum.java new file mode 100644 index 0000000..31f82f8 --- /dev/null +++ b/src/thinkingInJava/learning/collectionsFrame/Map/exer2/CityEnum.java @@ -0,0 +1,44 @@ +package thinkingInJava.learning.collectionsFrame.Map.exer2; + +public enum CityEnum { + DEFAULT(0, "error"), + SHAN_DONG(1, "山东"), + JI_LIN(2, "吉林"), + LIAO_NING(3, "辽宁"), + HE_BEI(4, "河北"), + HE_NAN(5, "河南"), + BEI_JING(6, "北京"); + + private int type; + private String province; + + public static CityEnum getCityByType(int type) { + for (CityEnum cityEnum : CityEnum.values()) { + if (type == cityEnum.getType()) { + return cityEnum; + } + } + return DEFAULT; + } + + CityEnum(int type, String province) { + this.type = type; + this.province = province; + } + + public int getType() { + return type; + } + + public void setType(int type) { + this.type = type; + } + + public String getProvince() { + return province; + } + + public void setProvince(String province) { + this.province = province; + } +} diff --git a/src/thinkingInJava/learning/collectionsFrame/Map/exer2/CityMap.java b/src/thinkingInJava/learning/collectionsFrame/Map/exer2/CityMap.java new file mode 100644 index 0000000..adbae19 --- /dev/null +++ b/src/thinkingInJava/learning/collectionsFrame/Map/exer2/CityMap.java @@ -0,0 +1,19 @@ +package thinkingInJava.learning.collectionsFrame.Map.exer2; + +import java.util.HashMap; +import java.util.Map; + +public class CityMap { + public static Map model = new HashMap<>(); + + static { + model.put("北京", new String[]{"北京"}); + model.put("辽宁", new String[]{"沈阳","盘锦","铁岭","丹东","大连","锦州","营口"}); + model.put("吉林", new String[]{"长春","延边","吉林","白山","白城","四平","松原"}); + model.put("河北", new String[]{"承德","沧州","邯郸","邢台","唐山","保定","石家庄"}); + model.put("河南", new String[]{"郑州","许昌","开封","洛阳","商丘","南阳","新乡"}); + model.put("山东", new String[]{"济南","青岛","日照","临沂","泰安","聊城","德州"}); + + } + +} diff --git a/src/thinkingInJava/learning/collectionsFrame/Map/exer2/Exer2_Two_class_move.java b/src/thinkingInJava/learning/collectionsFrame/Map/exer2/Exer2_Two_class_move.java new file mode 100644 index 0000000..6836564 --- /dev/null +++ b/src/thinkingInJava/learning/collectionsFrame/Map/exer2/Exer2_Two_class_move.java @@ -0,0 +1,47 @@ +package thinkingInJava.learning.collectionsFrame.Map.exer2; + +import java.util.Arrays; +import java.util.Iterator; +import java.util.Scanner; +import java.util.Set; + +public class Exer2_Two_class_move { + public static void main(String[] args) { + Set keySet = CityMap.model.keySet(); + Scanner scanner = new Scanner(System.in); + boolean flag = true; + while (flag) { + System.out.println("查询省份?(1/0)"); + switch (scanner.nextInt()) { + case 0: + flag = false; + break; + case 1: + System.out.println(keySet); + System.out.println("请选择你的省份(1-6):"); + int type = scanner.nextInt(); + CityEnum cityEnum = CityEnum.getCityByType(type); + + String provinceKey = cityEnum.getProvince(); + String[] citys = (String[]) CityMap.model.get(provinceKey); + //打印城市 + for (String city : citys) { + System.out.print(city+" "); + } + System.out.println(); + + l:while (true) { + System.out.println("请选择你所在的城市:"); + String cityName = scanner.next(); + for (int i = 0; i < citys.length; i++) { + if (citys[i].equals(cityName)) { + System.out.println("信息登记完毕"); + break l; + } + } + System.out.println("输入有误,请重新输入"); + } + } + } + } +} diff --git "a/src/thinkingInJava/learning/collectionsFrame/Map/exer2/\344\272\214\347\272\247\350\201\224\345\212\250.png" "b/src/thinkingInJava/learning/collectionsFrame/Map/exer2/\344\272\214\347\272\247\350\201\224\345\212\250.png" new file mode 100644 index 0000000..a5fe184 Binary files /dev/null and "b/src/thinkingInJava/learning/collectionsFrame/Map/exer2/\344\272\214\347\272\247\350\201\224\345\212\250.png" differ diff --git "a/src/thinkingInJava/learning/collectionsFrame/Map/exer2/\346\225\210\346\236\234.png" "b/src/thinkingInJava/learning/collectionsFrame/Map/exer2/\346\225\210\346\236\234.png" new file mode 100644 index 0000000..7449cbc Binary files /dev/null and "b/src/thinkingInJava/learning/collectionsFrame/Map/exer2/\346\225\210\346\236\234.png" differ diff --git a/src/thinkingInJava/learning/collectionsFrame/Map/info-config.properties b/src/thinkingInJava/learning/collectionsFrame/Map/info-config.properties new file mode 100644 index 0000000..998b4e1 --- /dev/null +++ b/src/thinkingInJava/learning/collectionsFrame/Map/info-config.properties @@ -0,0 +1,2 @@ +name=Tom Cruse +psw=qwe123 \ No newline at end of file diff --git a/src/thinkingInJava/learning/collectionsFrame/SourceCodeTest.java b/src/thinkingInJava/learning/collectionsFrame/SourceCodeTest.java new file mode 100644 index 0000000..0dbef43 --- /dev/null +++ b/src/thinkingInJava/learning/collectionsFrame/SourceCodeTest.java @@ -0,0 +1,41 @@ +package thinkingInJava.learning.collectionsFrame; + +import org.junit.Test; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.Map; + +public class SourceCodeTest { + @Test + public void test1() { + ArrayList list = new ArrayList<>(); + + list.add("aA"); + list.add("bB"); + list.add("cC"); + } + + @Test + public void test2() { + LinkedList list = new LinkedList<>(); + + list.add("aA"); + list.add("bB"); + list.add("cC"); + } + + @Test + public void test3() { + HashMap map = new HashMap(); + + map.put("key1", 123); + map.put("key2", 123); + map.put("key3", 123); + map.put("key4", 123); + map.put("key1", 467); + + + } +} diff --git a/src/thinkingInJava/learning/collectionsFrame/collectionsUtil/CollectionUtilTest.java b/src/thinkingInJava/learning/collectionsFrame/collectionsUtil/CollectionUtilTest.java new file mode 100644 index 0000000..e16ed8e --- /dev/null +++ b/src/thinkingInJava/learning/collectionsFrame/collectionsUtil/CollectionUtilTest.java @@ -0,0 +1,65 @@ +package thinkingInJava.learning.collectionsFrame.collectionsUtil; + +import org.junit.Test; +import thinkingInJava.learning.collectionsFrame.Collection.List.Person; + +import java.util.*; + +public class CollectionUtilTest { + @Test + public void test1() { + List coll = new ArrayList(); + + coll.add("AA"); + coll.add(128);// 自动装箱 + coll.add("尚硅谷");// 自动拆箱 + coll.add(new Object()); + coll.add(new Person("Wwx", 30)); + + + Collections.reverse(coll); + System.out.println(coll); + + Collections.shuffle(coll); + System.out.println(coll); + + } + + @Test + public void test2() { + List coll = new ArrayList(); + while (coll.size() < 20) { + int v = (int) (Math.random() * (30 - 10) + 30); + coll.add(v); + } + Collections.sort(coll); + System.out.println(coll); + Comparator comparator = new Comparator() { + @Override + public int compare(Object o1, Object o2) { + if (o1 instanceof Integer && o2 instanceof Integer) { + Integer oo1 = (Integer) o1; + Integer oo2 = (Integer) o2; + + if (oo1.compareTo(oo2) != 0) { + return -(oo1 - oo2); + } else { + return 0; + } + } + throw new RuntimeException("类型不匹配"); + } + }; + Collections.sort(coll, comparator); + System.out.println(coll); + } + @Test + public void test3() { + List coll = new ArrayList(); + while (coll.size() < 20) { + int v = (int) (Math.random() * (30 - 10) + 30); + coll.add(v); + } + System.out.println(Collections.max(coll)); + } +} diff --git a/src/thinkingInJava/learning/collectionsFrame/collectionsUtil/exer1_xi_pai/Exer1.java b/src/thinkingInJava/learning/collectionsFrame/collectionsUtil/exer1_xi_pai/Exer1.java new file mode 100644 index 0000000..998a9a6 --- /dev/null +++ b/src/thinkingInJava/learning/collectionsFrame/collectionsUtil/exer1_xi_pai/Exer1.java @@ -0,0 +1,58 @@ +package thinkingInJava.learning.collectionsFrame.collectionsUtil.exer1_xi_pai; + +import java.util.*; + +public class Exer1 { + public static void main(String[] args) { + String[] num = {"A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"}; + String[] color = {"方块?", "梅花?", "红桃?", "黑桃?"}; + ArrayList poker = new ArrayList(); + //1组排 + for (int i = 0; i < color.length; i++) { + for (int j = 0; j < num.length; j++) { + poker.add(color[i] + num[j]); + } + } + poker.add("大王Joker"); + poker.add("小王joker"); + System.out.println(poker); + + //2洗牌 + Collections.shuffle(poker); + + //3发牌 + // 创建3个角色,和一个底牌 + ArrayList p1 = new ArrayList(); + ArrayList p2 = new ArrayList(); + ArrayList p3 = new ArrayList(); + ArrayList table = new ArrayList(); + for (int i = 0; i < poker.size(); i++) { + if (i >= poker.size() - 3) { + table.add(poker.get(i)); + } else if (i % 3 == 0) { + p1.add(poker.get(i)); + } else if (i % 3 == 1) { + p2.add(poker.get(i)); + } else if (i % 3 == 2) { + p3.add(poker.get(i)); + } + } + + //4遍历 + printCard(p1, "tom"); + printCard(p2, "frank"); + printCard(p3, "william"); + printCard(table, "底牌"); + } + + static void printCard(List list,String player) { + Iterator iterator = list.iterator(); + System.out.println(player+":"); + System.out.print("["); + while (iterator.hasNext()) { + System.out.print(iterator.next()+" "); + } + System.out.print("]"); + System.out.println(); + } +} diff --git "a/src/thinkingInJava/learning/collectionsFrame/collectionsUtil/exer1_xi_pai/\346\264\227\347\211\214.png" "b/src/thinkingInJava/learning/collectionsFrame/collectionsUtil/exer1_xi_pai/\346\264\227\347\211\214.png" new file mode 100644 index 0000000..0f62048 Binary files /dev/null and "b/src/thinkingInJava/learning/collectionsFrame/collectionsUtil/exer1_xi_pai/\346\264\227\347\211\214.png" differ diff --git a/src/thinkingInJava/learning/dataStructure/DataStructureTest.java b/src/thinkingInJava/learning/dataStructure/DataStructureTest.java new file mode 100644 index 0000000..3d0b80f --- /dev/null +++ b/src/thinkingInJava/learning/dataStructure/DataStructureTest.java @@ -0,0 +1,38 @@ +package thinkingInJava.learning.dataStructure; + +import org.junit.Test; +import thinkingInJava.learning.dataStructure.queue.NodeQueue; +import thinkingInJava.learning.dataStructure.stack.NodeStack; + +public class DataStructureTest { + @Test + public void stackTest() { + NodeStack stack = new NodeStack(6); + for (int i = 0; i < 6; i++) { + stack.push(i); + } + //出栈前的栈 + System.out.println(stack); + //出栈 + System.out.println(stack.pop()); + //出栈后的栈 + System.out.println(stack); + + } + + @Test + public void queueTest() { + NodeQueue queue = new NodeQueue(6); + for (int i = 0; i < 6; i++) { + queue.add(i); + } + + //出队前的队 + System.out.println(queue); + //出队 + System.out.println(queue.get()); + //出队后的队 + System.out.println(queue); + + } +} diff --git a/src/thinkingInJava/learning/dataStructure/queue/NodeQueue.java b/src/thinkingInJava/learning/dataStructure/queue/NodeQueue.java new file mode 100644 index 0000000..4bf5a09 --- /dev/null +++ b/src/thinkingInJava/learning/dataStructure/queue/NodeQueue.java @@ -0,0 +1,42 @@ +package thinkingInJava.learning.dataStructure.queue; + +import java.util.Arrays; + +public class NodeQueue { + Object[] values; + int size; + + public NodeQueue(int length) { + values = new Object[length]; + } + + public void add(Object ele) { + if (size >= values.length) { + throw new RuntimeException("队列满,入队失败"); + } + values[size] = ele; + size++; + } + + public Object get() { + if (size <= 0) { + throw new RuntimeException("队列空,出队失败"); + } + Object res = values[0]; + //数组前移 + for (int i = 0; i < size - 1; i++) { + values[i] = values[i + 1]; + } + values[size - 1] = null; + size--; + return res; + } + + @Override + public String toString() { + return "Node{" + + "values=" + Arrays.toString(values) + + ", size=" + size + + '}'; + } +} diff --git a/src/thinkingInJava/learning/dataStructure/stack/NodeStack.java b/src/thinkingInJava/learning/dataStructure/stack/NodeStack.java new file mode 100644 index 0000000..ed7d1fa --- /dev/null +++ b/src/thinkingInJava/learning/dataStructure/stack/NodeStack.java @@ -0,0 +1,38 @@ +package thinkingInJava.learning.dataStructure.stack; + +import java.util.Arrays; + +public class NodeStack { + Object[] values; + int size;//记录存储元素的个数 + + public NodeStack(int length) { + values = new Object[length]; + } + + public void push(Object ele) { + if (size >= values.length) { + throw new RuntimeException("栈满,插入失败"); + } + values[size] = ele; + size++; + } + + public Object pop() { + if (size <= 0) { + throw new RuntimeException("栈空,获取失败"); + } + Object res = values[size - 1]; //取栈顶 + values[size - 1] = null; + size--; + return res; + } + + @Override + public String toString() { + return "Node{" + + "values=" + Arrays.toString(values) + + ", size=" + size + + '}'; + } +} diff --git a/src/thinkingInJava/learning/fileAndIOStream/FileAndIOTest.java b/src/thinkingInJava/learning/fileAndIOStream/FileAndIOTest.java new file mode 100644 index 0000000..0b2c10e --- /dev/null +++ b/src/thinkingInJava/learning/fileAndIOStream/FileAndIOTest.java @@ -0,0 +1,47 @@ +package thinkingInJava.learning.fileAndIOStream; + +import org.junit.Test; + +import java.io.*; + +public class FileAndIOTest { + + @Test + public void FileTest() throws IOException { + File file = new File("src/thinkingInJava/learning/fileAndIOStream/"); + System.out.println(file.length()); + String[] list = file.list(); + for (String o : list) { + System.out.println(o); + } + } + + @Test + public void FileTest1() throws IOException { + File file = new File("src/thinkingInJava/learning/fileAndIOStream/fat.txt"); + boolean b = file.renameTo(new File("src/thinkingInJava/learning/fileAndIOStream/tess.txt")); + System.out.println(b); + } + + @Test + public void FileTest2() throws IOException { + File file = new File("src/thinkingInJava/learning/fileAndIOStream/fat.txt"); + boolean newFile = file.createNewFile(); + System.out.println(newFile); + File file1 = new File("src/thinkingInJava/learning/fileAndIOStream/mkdirT"); + boolean mkdir = file1.mkdirs(); + boolean delete = file1.delete(); + System.out.println(mkdir); + } + + @Test + public void FileTest3() { + File file = new File("src/thinkingInJava/learning/fileAndIOStream/"); + String[] list = file.list(); + for (int i = 0; i < list.length; i++) { + System.out.println(list[i].substring(0, list[i].indexOf('.'))); + System.out.println(list[i].substring(list[i].indexOf('.')+1)); + + } + } +} diff --git a/src/thinkingInJava/learning/fileAndIOStream/exer1/Exer1.java b/src/thinkingInJava/learning/fileAndIOStream/exer1/Exer1.java new file mode 100644 index 0000000..76211b0 --- /dev/null +++ b/src/thinkingInJava/learning/fileAndIOStream/exer1/Exer1.java @@ -0,0 +1,45 @@ +package thinkingInJava.learning.fileAndIOStream.exer1; + +import org.junit.Test; + +import java.io.File; +import java.io.FilenameFilter; + +public class Exer1 { + @Test + public void test1() { + File file = new File("D:\\DevProj\\Java\\reviewJava\\src\\thinkingInJava\\learning\\fileAndIOStream\\exer1\\"); + String[] list = file.list(); + for (int i = 0; i < list.length; i++) { + if (list[i].substring(list[i].indexOf('.') + 1).equals("png")) { + System.out.println(list[i].substring(0, list[i].indexOf('.'))); + } + } + } + + @Test + public void test2() { + File file = new File("D:\\DevProj\\Java\\reviewJava\\src\\thinkingInJava\\learning\\fileAndIOStream\\exer1\\"); + String[] list = file.list(); + for (int i = 0; i < list.length; i++) { + if (list[i].endsWith(".png")) { + System.out.println(list[i]); + } + } + } + + @Test + public void test3() { + File file = new File("D:\\DevProj\\Java\\reviewJava\\src\\thinkingInJava\\learning\\fileAndIOStream\\exer1\\"); + String[] list = file.list(new FilenameFilter() { + @Override + public boolean accept(File dir, String name) { //name: 为子文件或子文件目录的名称 + return name.endsWith(".png"); + } + }); + + for (String s : list) { + System.out.println(s); + } + } +} diff --git a/src/thinkingInJava/learning/fileAndIOStream/exer1/img.png b/src/thinkingInJava/learning/fileAndIOStream/exer1/img.png new file mode 100644 index 0000000..85be8fa Binary files /dev/null and b/src/thinkingInJava/learning/fileAndIOStream/exer1/img.png differ diff --git a/src/thinkingInJava/learning/fileAndIOStream/fas.txt b/src/thinkingInJava/learning/fileAndIOStream/fas.txt new file mode 100644 index 0000000..e69de29 diff --git a/src/thinkingInJava/learning/fileAndIOStream/fat.txt b/src/thinkingInJava/learning/fileAndIOStream/fat.txt new file mode 100644 index 0000000..e69de29 diff --git a/src/thinkingInJava/learning/fileAndIOStream/fileStream/BufferedStreamTest.java b/src/thinkingInJava/learning/fileAndIOStream/fileStream/BufferedStreamTest.java new file mode 100644 index 0000000..650dcef --- /dev/null +++ b/src/thinkingInJava/learning/fileAndIOStream/fileStream/BufferedStreamTest.java @@ -0,0 +1,111 @@ +package thinkingInJava.learning.fileAndIOStream.fileStream; + +import org.junit.Test; + +import java.io.*; + +public class BufferedStreamTest implements Serializable{ + @Test + public void test1() { + BufferedReader bufferedReader = null; + try { + bufferedReader = new BufferedReader(new FileReader(new File("src/thinkingInJava/learning/fileAndIOStream/fileStream/log2.txt"))); + char[] cBf = new char[1024]; + int len; + while ((len = bufferedReader.read(cBf)) != -1) { + for (int i = 0; i < len; i++) { + System.out.print(cBf[i]); + } + } + } catch (IOException e) { + e.printStackTrace(); + } finally { + try { + if (bufferedReader != null) { + bufferedReader.close(); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + @Test + public void test4() { + BufferedReader bufferedReader = null; + try { + bufferedReader = new BufferedReader(new FileReader(new File("src/thinkingInJava/learning/fileAndIOStream/fileStream/log3.txt"))); + String data; + while ((data = bufferedReader.readLine()) != null) { + System.out.println(data); + } + } catch (IOException e) { + e.printStackTrace(); + } finally { + try { + if (bufferedReader != null) { + bufferedReader.close(); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + + @Test + public void test3() { + BufferedReader bufferedReader = null; + BufferedWriter bufferedWriter = null; + try { + bufferedReader = new BufferedReader(new FileReader(new File("src/thinkingInJava/learning/fileAndIOStream/fileStream/log2.txt"))); + bufferedWriter = new BufferedWriter(new FileWriter(new File("src/thinkingInJava/learning/fileAndIOStream/fileStream/log3.txt"))); + char[] cBf = new char[1024]; + int len; + while ((len = bufferedReader.read(cBf)) != -1) { + for (int i = 0; i < len; i++) { + System.out.print(cBf[i]); + } + bufferedWriter.write(cBf, 0, len); + } + } catch (IOException e) { + e.printStackTrace(); + } finally { + try { + if (bufferedReader != null && bufferedWriter != null) { + bufferedReader.close(); + bufferedWriter.close(); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + @Test + public void test2() { + BufferedInputStream bis = null; + BufferedOutputStream bos = null; + try { + bis = new BufferedInputStream(new FileInputStream(new File("src/thinkingInJava/learning/fileAndIOStream/fileStream/img2.png"))); + bos = new BufferedOutputStream(new FileOutputStream(new File("src/thinkingInJava/learning/fileAndIOStream/fileStream/img3.png"))); + byte[] bytesBuffer = new byte[1024]; + int len; + while ((len = bis.read(bytesBuffer)) != -1) { + bos.write(bytesBuffer, 0, len); + } + } catch (IOException e) { + e.printStackTrace(); + } finally { + try { + if (bis != null && bos != null) { + bis.close(); + bos.close(); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + + } +} diff --git a/src/thinkingInJava/learning/fileAndIOStream/fileStream/FileStreamTest.java b/src/thinkingInJava/learning/fileAndIOStream/fileStream/FileStreamTest.java new file mode 100644 index 0000000..e7759fd --- /dev/null +++ b/src/thinkingInJava/learning/fileAndIOStream/fileStream/FileStreamTest.java @@ -0,0 +1,180 @@ +package thinkingInJava.learning.fileAndIOStream.fileStream; + +import org.junit.Test; + +import java.io.*; + +public class FileStreamTest { + @Test + public void test1() throws IOException { + FileReader fileReader = new FileReader(new File("src/thinkingInJava/learning/fileAndIOStream/fileStream/teff.txt")); + int data = fileReader.read(); + while (data != -1) { + System.out.print((char) data); + data = fileReader.read(); + } + + fileReader.close(); + } + + @Test + public void test2() { + Long start = System.currentTimeMillis(); + FileReader fileReader = null; + try { + fileReader = new FileReader(new File("src/thinkingInJava/learning/fileAndIOStream/fileStream/teff.txt")); + int data; + while ((data = fileReader.read()) != -1) { + System.out.print((char) data); + } + } catch (IOException e) { + e.printStackTrace(); + } finally { + try { + if (fileReader != null) { + fileReader.close(); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + Long end = System.currentTimeMillis(); + System.out.println(end - start); + + } + + @Test + public void test3() { + Long start = System.currentTimeMillis(); + FileReader fileReader = null; + try { + fileReader = new FileReader(new File("src/thinkingInJava/learning/fileAndIOStream/fileStream/teff.txt")); + //每次读取多个数据,使用一个char[] 数组来一次接受多个值 + char[] charBuff = new char[20]; +// int len = fileReader.read(charBuff);//获取读到charBuff中的字符长度 + int len; + while ((len = fileReader.read(charBuff)) != -1) { + for (int i = 0; i < len; i++) { + System.out.print(charBuff[i]); + } + } + } catch (IOException e) { + e.printStackTrace(); + } finally { + try { + if (fileReader != null) { + fileReader.close(); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + Long end = System.currentTimeMillis(); + System.out.println(end - start); + } + + @Test + public void test4() { + // 将内存中的数据写出到指定文件中 + FileReader fileReader = null; + FileWriter fileWriter = null; + try { + fileReader = new FileReader(new File("src/thinkingInJava/learning/fileAndIOStream/fileStream/teff.txt")); + fileWriter = new FileWriter(new File("src/thinkingInJava/learning/fileAndIOStream/fileStream/log2.txt")); + char[] cBuf = new char[30]; + int len; + while ((len = fileReader.read(cBuf)) != -1) { +// for (int i = 0; i < len; i++) { +// System.out.print(cBuf[i]); +// fileWriter.write(cBuf[i]); +// } + fileWriter.write(cBuf,0,len); + } + } catch (IOException e) { + e.printStackTrace(); + } finally { + try { + if (fileReader != null && fileWriter != null) { + fileReader.close(); + fileWriter.close(); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + + } + + @Test + public void test5() { + //读取图片和视频使用字节流,读取文本使用字符流 + FileInputStream fis = null; + try { + fis = new FileInputStream(new File("src/thinkingInJava/learning/fileAndIOStream/fileStream/img.png")); + byte[] bytes = new byte[1024];//1kb + int len; + while ((len = fis.read(bytes)) != -1) { + for (int i = 0; i < len; i++) { + System.out.print(bytes[i]); + } + } + } catch (IOException e) { + throw new RuntimeException(e); + } finally { + try { + if (fis != null) { + fis.close(); + } + } catch (IOException e) { + throw new RuntimeException(e); + } + } + } + + @Test + public void test6() { + //读取图片和视频使用字节流,读取文本使用字符流 + FileInputStream fis = null; + FileOutputStream fos = null; + try { + fis = new FileInputStream(new File("src/thinkingInJava/learning/fileAndIOStream/fileStream/img.png")); + fos = new FileOutputStream(new File("src/thinkingInJava/learning/fileAndIOStream/fileStream/img2.png")); + byte[] bytes = new byte[1024];//1kb + int len; + while ((len = fis.read(bytes)) != -1) { + for (int i = 0; i < len; i++) { + System.out.print(bytes[i]); + } + fos.write(bytes,0,len);//写入文件 + } + + } catch (IOException e) { + throw new RuntimeException(e); + } finally { + try { + if (fis != null && fos != null) { + fis.close(); + fos.close(); + } + } catch (IOException e) { + throw new RuntimeException(e); + } + } + } + + public static void main(String[] args) { + int res = test(10); + System.out.println(res); + } + + static int test(int n) { + try { + return n; + } catch (Exception e) { + return n--; + } finally { + System.out.println("end"); + ++n; + } + } +} diff --git a/src/thinkingInJava/learning/fileAndIOStream/fileStream/ObjectStreamTest.java b/src/thinkingInJava/learning/fileAndIOStream/fileStream/ObjectStreamTest.java new file mode 100644 index 0000000..250b50a --- /dev/null +++ b/src/thinkingInJava/learning/fileAndIOStream/fileStream/ObjectStreamTest.java @@ -0,0 +1,32 @@ +package thinkingInJava.learning.fileAndIOStream.fileStream; + +import org.junit.Test; + +import java.io.*; + +public class ObjectStreamTest { + @Test + public void test1() throws IOException { + //序列化 + File file = new File("src/thinkingInJava/learning/fileAndIOStream/fileStream/oosT.txt"); + ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(file)); + + //写入数据即为序列化过程 + oos.writeUTF("你好吗,我是你爹"); + oos.flush(); + + oos.close(); + } + + @Test + public void test2() throws IOException { + //反序列化 + File file = new File("src/thinkingInJava/learning/fileAndIOStream/fileStream/oosT.txt"); + ObjectInputStream ois = new ObjectInputStream(new FileInputStream(file)); + + String s = ois.readUTF(); + System.out.println(s); + + ois.close(); + } +} diff --git a/src/thinkingInJava/learning/fileAndIOStream/fileStream/img.png b/src/thinkingInJava/learning/fileAndIOStream/fileStream/img.png new file mode 100644 index 0000000..9f45f54 Binary files /dev/null and b/src/thinkingInJava/learning/fileAndIOStream/fileStream/img.png differ diff --git a/src/thinkingInJava/learning/fileAndIOStream/fileStream/img2.png b/src/thinkingInJava/learning/fileAndIOStream/fileStream/img2.png new file mode 100644 index 0000000..9f45f54 Binary files /dev/null and b/src/thinkingInJava/learning/fileAndIOStream/fileStream/img2.png differ diff --git a/src/thinkingInJava/learning/fileAndIOStream/fileStream/img3.png b/src/thinkingInJava/learning/fileAndIOStream/fileStream/img3.png new file mode 100644 index 0000000..9f45f54 Binary files /dev/null and b/src/thinkingInJava/learning/fileAndIOStream/fileStream/img3.png differ diff --git a/src/thinkingInJava/learning/fileAndIOStream/fileStream/log.txt b/src/thinkingInJava/learning/fileAndIOStream/fileStream/log.txt new file mode 100644 index 0000000..2a9dda7 --- /dev/null +++ b/src/thinkingInJava/learning/fileAndIOStream/fileStream/log.txt @@ -0,0 +1,19 @@ +Hello esteemed interviewer, + I'm delighted to be here today for this interview opportunity. My name is weiwenxu, +and I am currently a graduate student at Xi'an University of Architecture and Technology, +specializing in Electronic Information. + Throughout my academic journey, I've had the privilege of participating in the +"Huawei Cup" Graduate Mathematical Modeling Competition twice, earning both a +national third prize and a second prize. Additionally, I've been actively engaged +in academic research, having authored a paper on multi-task graph convolutional +neural networks, which I'm preparing to submit to relevant journals. + Beyond my academic achievements, I have a strong interest in backend development. +I've self-taught myself various technologies such as Java, Spring Boot, MySQL, and +MyBatis, and I've applied these skills to successfully develop a backend business logic +for a mall project named GgM. + I am fully aware of the rare opportunity it would be to join your esteemed industry. +If given the chance to be a part of your team, I am committed to cherishing this opportunity +and dedicating myself to continuous learning and growth, contributing my best efforts to the +company's success. + Thank you for considering me for this opportunity. I eagerly look forward to the possibility +of becoming a valuable member of your company. Thank you! \ No newline at end of file diff --git a/src/thinkingInJava/learning/fileAndIOStream/fileStream/log2.txt b/src/thinkingInJava/learning/fileAndIOStream/fileStream/log2.txt new file mode 100644 index 0000000..2a9dda7 --- /dev/null +++ b/src/thinkingInJava/learning/fileAndIOStream/fileStream/log2.txt @@ -0,0 +1,19 @@ +Hello esteemed interviewer, + I'm delighted to be here today for this interview opportunity. My name is weiwenxu, +and I am currently a graduate student at Xi'an University of Architecture and Technology, +specializing in Electronic Information. + Throughout my academic journey, I've had the privilege of participating in the +"Huawei Cup" Graduate Mathematical Modeling Competition twice, earning both a +national third prize and a second prize. Additionally, I've been actively engaged +in academic research, having authored a paper on multi-task graph convolutional +neural networks, which I'm preparing to submit to relevant journals. + Beyond my academic achievements, I have a strong interest in backend development. +I've self-taught myself various technologies such as Java, Spring Boot, MySQL, and +MyBatis, and I've applied these skills to successfully develop a backend business logic +for a mall project named GgM. + I am fully aware of the rare opportunity it would be to join your esteemed industry. +If given the chance to be a part of your team, I am committed to cherishing this opportunity +and dedicating myself to continuous learning and growth, contributing my best efforts to the +company's success. + Thank you for considering me for this opportunity. I eagerly look forward to the possibility +of becoming a valuable member of your company. Thank you! \ No newline at end of file diff --git a/src/thinkingInJava/learning/fileAndIOStream/fileStream/log3.txt b/src/thinkingInJava/learning/fileAndIOStream/fileStream/log3.txt new file mode 100644 index 0000000..030ba9b --- /dev/null +++ b/src/thinkingInJava/learning/fileAndIOStream/fileStream/log3.txt @@ -0,0 +1,18 @@ +Hello esteemed interviewer, + I'm delighted to be here today for this interview opportunity. My name is weiwenxu, +and I am currently a graduate student at Xi'an University of Architecture and Technology, +majoring in Electronic Information. + Throughout my academic journey, I've had the privilege of participating in the +"Huawei Cup" Graduate Mathematical Modeling Competition twice, earning both a +national third prize and a second prize respectivly. Additionally, I've been actively engaged +in academic research, having authored a paper on multi-task graph convolutional +neural networks, which I'm preparing to submit to relevant journals. + Beyond my academic achievements, I have a strong interest in backend development. +I've self-taught myself various technologies such as Java, Spring Boot, MySQL, and +MyBatis, and I've applied these skills to successfully develop a backend business logic +for a mall project named GgM. + I am fully aware of the rare opportunity to join you.If given the chance to be a part of your team, +I am committed to cherishing this opportunity and dedicating myself to continuous learning and growth, +contributing my best efforts to the company's success. + Thank you for considering me for this opportunity. I am eagerly looking forward to have the chance to join you. +Thank you! \ No newline at end of file diff --git a/src/thinkingInJava/learning/fileAndIOStream/fileStream/oosT.txt b/src/thinkingInJava/learning/fileAndIOStream/fileStream/oosT.txt new file mode 100644 index 0000000..f12e592 Binary files /dev/null and b/src/thinkingInJava/learning/fileAndIOStream/fileStream/oosT.txt differ diff --git a/src/thinkingInJava/learning/fileAndIOStream/fileStream/teff.txt b/src/thinkingInJava/learning/fileAndIOStream/fileStream/teff.txt new file mode 100644 index 0000000..e69de29 diff --git a/src/thinkingInJava/learning/fileAndIOStream/objectIo/ObjectIOTest.java b/src/thinkingInJava/learning/fileAndIOStream/objectIo/ObjectIOTest.java new file mode 100644 index 0000000..1cbf929 --- /dev/null +++ b/src/thinkingInJava/learning/fileAndIOStream/objectIo/ObjectIOTest.java @@ -0,0 +1,34 @@ +package thinkingInJava.learning.fileAndIOStream.objectIo; + +import org.junit.Test; + +import java.io.*; + +public class ObjectIOTest { + //序列化 + @Test + public void test1() throws IOException { + ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(new File("object.dat"))); + + //2. shuju + PeopleT p1 = new PeopleT("abc", 123,"xa"); + oos.writeObject(p1); + oos.flush(); + + oos.close(); + } + + //反序列化 + @Test + public void test2() throws IOException, ClassNotFoundException { + ObjectInputStream ois = new ObjectInputStream(new FileInputStream(new File("object.dat"))); + Object o = ois.readObject(); + if (o instanceof PeopleT) { + PeopleT p = (PeopleT) o; + System.out.println(p.getName() + "\t" + p.getAge()+"\t"+p.getAdd()); + } + + ois.close(); + + } +} diff --git a/src/thinkingInJava/learning/fileAndIOStream/objectIo/PeopleT.java b/src/thinkingInJava/learning/fileAndIOStream/objectIo/PeopleT.java new file mode 100644 index 0000000..328b11a --- /dev/null +++ b/src/thinkingInJava/learning/fileAndIOStream/objectIo/PeopleT.java @@ -0,0 +1,51 @@ +package thinkingInJava.learning.fileAndIOStream.objectIo; + +import java.io.Serializable; +import java.math.BigDecimal; + +public class PeopleT implements Serializable { + public static final long servialVersionUID = -89793831241217425L; + private String name; + private int age; + private String add; + + + public PeopleT(String name, int age,String add) { + this.name = name; + this.age = age; + this.add = add; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getAge() { + return age; + } + + public void setAge(int age) { + this.age = age; + } + + public String getAdd() { + return add; + } + + @Override + public String toString() { + return "PeopleT{" + + "name='" + name + '\'' + + ", age=" + age + + ", add='" + add + '\'' + + '}'; + } + + public void setAdd(String add) { + this.add = add; + } +} diff --git a/src/thinkingInJava/learning/fileAndIOStream/tess.txt b/src/thinkingInJava/learning/fileAndIOStream/tess.txt new file mode 100644 index 0000000..91b0331 --- /dev/null +++ b/src/thinkingInJava/learning/fileAndIOStream/tess.txt @@ -0,0 +1,6 @@ +hello +jessy +billy +jerry +merry +kk \ No newline at end of file diff --git a/src/thinkingInJava/learning/genericity/selfDefine/GenericityTest2.java b/src/thinkingInJava/learning/genericity/selfDefine/GenericityTest2.java new file mode 100644 index 0000000..8230050 --- /dev/null +++ b/src/thinkingInJava/learning/genericity/selfDefine/GenericityTest2.java @@ -0,0 +1,19 @@ +package thinkingInJava.learning.genericity.selfDefine; + +public class GenericityTest2 { + + // 泛型方法 + public E genericityMethod(E e) { + return e; + } + + public static void main(String[] args) { + System.out.println(Math.ceil(5.3));//6.0 + System.out.println(Math.round(5.3));//5 + System.out.println(42 >> 3); //5 + System.out.println(2 >> 3); //0 + System.out.println(2 << 3); //16 + System.out.println(2 << 3 >> 2); //4 + + } +} diff --git a/src/thinkingInJava/learning/genericity/use/GenericityTest.java b/src/thinkingInJava/learning/genericity/use/GenericityTest.java new file mode 100644 index 0000000..dcf6970 --- /dev/null +++ b/src/thinkingInJava/learning/genericity/use/GenericityTest.java @@ -0,0 +1,26 @@ +package thinkingInJava.learning.genericity.use; + +import org.junit.Test; +import thinkingInJava.learning.collectionsFrame.Collection.List.Person; + +import java.util.ArrayList; +import java.util.List; + +public class GenericityTest { + + @Test + public void test1() { + List a = new ArrayList<>(); + + a.add(12); + a.add(15); + a.add(88); + a.add(98); + a.add(Integer.parseInt("123")); + a.add((int) 'c'); + + System.out.println(a); + } +} + + diff --git a/src/thinkingInJava/learning/genericity/use/exer1/Exer.java b/src/thinkingInJava/learning/genericity/use/exer1/Exer.java new file mode 100644 index 0000000..334a198 --- /dev/null +++ b/src/thinkingInJava/learning/genericity/use/exer1/Exer.java @@ -0,0 +1,38 @@ +package thinkingInJava.learning.genericity.use.exer1; + +import org.junit.Test; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.function.Predicate; + +public class Exer { + // + @Test + public void test() { + ArrayList list = new ArrayList<>(); + + for (int i = 0; i < 10; i++) { + list.add((int) (Math.random() * (100 - 0) + 0)); //[0,100) + } + + for (Integer i : list) { + System.out.println(i); + } + + list.removeIf(new Predicate() { + @Override + public boolean test(Integer integer) { + return integer % 2 == 0; + } + }); + + System.out.println("删除后:"); + + Iterator iterator = list.iterator(); + while (iterator.hasNext()) { + System.out.println(iterator.next()); + } + } +} diff --git a/src/thinkingInJava/learning/genericity/use/exer1/img.png b/src/thinkingInJava/learning/genericity/use/exer1/img.png new file mode 100644 index 0000000..cca29ae Binary files /dev/null and b/src/thinkingInJava/learning/genericity/use/exer1/img.png differ diff --git a/src/thinkingInJava/learning/internet/InternetTest.java b/src/thinkingInJava/learning/internet/InternetTest.java new file mode 100644 index 0000000..c697f9d --- /dev/null +++ b/src/thinkingInJava/learning/internet/InternetTest.java @@ -0,0 +1,24 @@ +package thinkingInJava.learning.internet; + +import org.junit.Test; +import sun.net.spi.nameservice.dns.DNSNameService; + +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.nio.charset.StandardCharsets; + +public class InternetTest { + @Test + public void test1() throws UnknownHostException { + InetAddress tencentCloud = InetAddress.getByName("49.233.249.46"); + System.out.println(tencentCloud); + + InetAddress add2 = InetAddress.getByName("www.x.com"); + System.out.println(add2); + + InetAddress localHost = InetAddress.getLocalHost(); + System.out.println(localHost); + } + + +} diff --git a/src/thinkingInJava/learning/internet/chat/ChatClient.java b/src/thinkingInJava/learning/internet/chat/ChatClient.java new file mode 100644 index 0000000..d51cd61 --- /dev/null +++ b/src/thinkingInJava/learning/internet/chat/ChatClient.java @@ -0,0 +1,5 @@ +package thinkingInJava.learning.internet.chat; + +public class ChatClient { + +} diff --git a/src/thinkingInJava/learning/internet/chat/ChatServer.java b/src/thinkingInJava/learning/internet/chat/ChatServer.java new file mode 100644 index 0000000..27decba --- /dev/null +++ b/src/thinkingInJava/learning/internet/chat/ChatServer.java @@ -0,0 +1,5 @@ +package thinkingInJava.learning.internet.chat; + +public class ChatServer { + +} diff --git a/src/thinkingInJava/learning/internet/exer1/Exer1.java b/src/thinkingInJava/learning/internet/exer1/Exer1.java new file mode 100644 index 0000000..9d09f22 --- /dev/null +++ b/src/thinkingInJava/learning/internet/exer1/Exer1.java @@ -0,0 +1,75 @@ +package thinkingInJava.learning.internet.exer1; + +import org.junit.Test; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.InetAddress; +import java.net.ServerSocket; +import java.net.Socket; +import java.net.UnknownHostException; +import java.nio.charset.StandardCharsets; + +public class Exer1 { + @Test + public void client() { + //创建socket + Socket socket = null; + OutputStream outputStream = null; + try { + InetAddress addr = InetAddress.getByName("127.0.0.1"); + int port = 8989; + socket = new Socket(addr, port); + //发送数据 + outputStream = socket.getOutputStream(); + outputStream.write("客户端".getBytes()); + } catch (IOException e) { + throw new RuntimeException(e); + } finally { + //关闭socket + try { + socket.close(); + outputStream.close(); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + + } + + @Test + public void server() { + //创建一个ServerSocket + int port = 8989; + ServerSocket serverSocket = null; + Socket accept = null; + InputStream inputStream = null; + try { + serverSocket = new ServerSocket(port); + //调用accept(),接受客户端的socket + accept = serverSocket.accept(); + + //接收数据 + inputStream = accept.getInputStream(); + byte[] bf = new byte[1024]; + int len; + while ((len = inputStream.read(bf)) != -1) { + String s = new String(bf, 0, len); + System.out.println(s); + } + } catch (IOException e) { + throw new RuntimeException(e); + } finally { + try { + //关闭socket + inputStream.close(); + accept.close(); + serverSocket.close(); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + } +} diff --git a/src/thinkingInJava/learning/internet/exer1/img.png b/src/thinkingInJava/learning/internet/exer1/img.png new file mode 100644 index 0000000..4137c1f Binary files /dev/null and b/src/thinkingInJava/learning/internet/exer1/img.png differ diff --git a/src/thinkingInJava/learning/internet/exer2/Exer2.java b/src/thinkingInJava/learning/internet/exer2/Exer2.java new file mode 100644 index 0000000..dfd0e53 --- /dev/null +++ b/src/thinkingInJava/learning/internet/exer2/Exer2.java @@ -0,0 +1,79 @@ +package thinkingInJava.learning.internet.exer2; + +import org.junit.Test; + +import java.io.*; +import java.net.InetAddress; +import java.net.ServerSocket; +import java.net.Socket; + +public class Exer2 { + @Test + public void client() { + FileInputStream fis = null; + Socket socket = null; + OutputStream os = null; + try { + fis = new FileInputStream(new File("oosT.txt")); + //1.创建socket + //1.1host + InetAddress host = InetAddress.getByName("127.0.0.1"); + //1.2port + int port = 8989; + socket = new Socket(host, port); + + //2.发送数据 + os = socket.getOutputStream(); + byte[] bf = new byte[1024]; + int len; + while ((len = fis.read(bf)) != -1) { + String temp = new String(bf, 0, len); +// os.write(temp.getBytes()); + os.write(bf,0,len); + } + } catch (IOException e) { + e.printStackTrace(); + } finally { + try { + //3.关闭socket + socket.close(); + fis.close(); + os.close(); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + } + + @Test + public void server(){ + ServerSocket serverSocket = null; + Socket accept = null; + InputStream inputStream = null; + try { + int port = 8989; + //1.创建serversocket + serverSocket = new ServerSocket(port); + //接收数据 + accept = serverSocket.accept(); + inputStream = accept.getInputStream(); + byte[] bf = new byte[1024]; + int len; + while ((len = inputStream.read(bf)) != -1) { + String temp = new String(bf, 0, len); + System.out.println(temp); + } + } catch (IOException e) { + e.printStackTrace(); + } finally { + try { + //关闭socket + inputStream.close(); + accept.close(); + serverSocket.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } +} diff --git a/src/thinkingInJava/learning/internet/exer2/img_1.png b/src/thinkingInJava/learning/internet/exer2/img_1.png new file mode 100644 index 0000000..3192ddc Binary files /dev/null and b/src/thinkingInJava/learning/internet/exer2/img_1.png differ diff --git a/src/thinkingInJava/learning/internet/exer3/Exer3.java b/src/thinkingInJava/learning/internet/exer3/Exer3.java new file mode 100644 index 0000000..0284d54 --- /dev/null +++ b/src/thinkingInJava/learning/internet/exer3/Exer3.java @@ -0,0 +1,101 @@ +package thinkingInJava.learning.internet.exer3; + +import org.junit.Test; + +import java.io.*; +import java.net.InetAddress; +import java.net.ServerSocket; +import java.net.Socket; + +public class Exer3 { + @Test + public void client() { + FileInputStream fileInputStream = null; + Socket socket = null; + OutputStream os = null; + InputStream inputStream = null; + try { + fileInputStream = new FileInputStream(new File("src/thinkingInJava/learning/internet/exer3/test.png")); + int port = 8989; + InetAddress host = InetAddress.getByName("127.0.0.1"); + //socket + socket = new Socket(host, port); + //发送数据 + os = socket.getOutputStream(); + byte[] buffer = new byte[1024]; + int len; + while ((len = fileInputStream.read(buffer)) != -1) { + os.write(buffer, 0, len); + } + System.out.println("客户端发送成功!"); + //客户端表明不再继续发数据 + socket.shutdownOutput(); + + //接受服务器消息 + inputStream = socket.getInputStream(); + byte[] buff = new byte[10]; + int len1; + while ((len1 = inputStream.read(buff)) != -1) { + String temp = new String(buff, 0, len1); + System.out.println(temp); + } + } catch (IOException e) { + throw new RuntimeException(e); + } finally { + try { + //关闭socket + fileInputStream.close(); + socket.close(); + os.close(); + inputStream.close(); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + } + + @Test + public void server() { + FileOutputStream fos = null; + ServerSocket serverSocket = null; + Socket accept = null; + InputStream is = null; + OutputStream os = null; + try { + int port = 8989; + fos = new FileOutputStream(new File("src/thinkingInJava/learning/internet/exer3/test谢谢_copy.png")); + //serverSocket + serverSocket = new ServerSocket(port); + //接受Socket : accept() + accept = serverSocket.accept(); + is = accept.getInputStream(); + byte[] buff = new byte[1024]; + int len; + //保存当地 + while ((len = is.read(buff)) != -1) { + fos.write(buff, 0, len); + } + System.out.println("服务器接收成功!"); + + + //服务器发送数据给客户端 + os= accept.getOutputStream(); + os.write("接收成功!".getBytes()); + + } catch (IOException e) { + throw new RuntimeException(e); + } finally { + try { + //关闭 + fos.close(); + serverSocket.close(); + accept.close(); + is.close(); + os.close(); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + } +} diff --git a/src/thinkingInJava/learning/internet/exer3/img.png b/src/thinkingInJava/learning/internet/exer3/img.png new file mode 100644 index 0000000..b74949a Binary files /dev/null and b/src/thinkingInJava/learning/internet/exer3/img.png differ diff --git a/src/thinkingInJava/learning/internet/exer3/test.png b/src/thinkingInJava/learning/internet/exer3/test.png new file mode 100644 index 0000000..61d5076 Binary files /dev/null and b/src/thinkingInJava/learning/internet/exer3/test.png differ diff --git a/src/thinkingInJava/learning/internet/exer3/test2_copy.png b/src/thinkingInJava/learning/internet/exer3/test2_copy.png new file mode 100644 index 0000000..61d5076 Binary files /dev/null and b/src/thinkingInJava/learning/internet/exer3/test2_copy.png differ diff --git a/src/thinkingInJava/learning/internet/exer3/test_copy.png b/src/thinkingInJava/learning/internet/exer3/test_copy.png new file mode 100644 index 0000000..61d5076 Binary files /dev/null and b/src/thinkingInJava/learning/internet/exer3/test_copy.png differ diff --git "a/src/thinkingInJava/learning/internet/exer3/test\350\260\242\350\260\242_copy.png" "b/src/thinkingInJava/learning/internet/exer3/test\350\260\242\350\260\242_copy.png" new file mode 100644 index 0000000..61d5076 Binary files /dev/null and "b/src/thinkingInJava/learning/internet/exer3/test\350\260\242\350\260\242_copy.png" differ diff --git a/src/thinkingInJava/learning/reflection/PersonPP.java b/src/thinkingInJava/learning/reflection/PersonPP.java new file mode 100644 index 0000000..df12950 --- /dev/null +++ b/src/thinkingInJava/learning/reflection/PersonPP.java @@ -0,0 +1,53 @@ +package thinkingInJava.learning.reflection; + +import java.io.Serializable; + +public class PersonPP extends PersonSu implements Serializable { + private String name; + public int age; + + public PersonPP() { + System.out.println("PersonPP()..."); + } + + static { + System.out.println("static {...}"); + } + + private PersonPP(String name, int age) { + this.name = name; + this.age = age; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getAge() { + return age; + } + + public void setAge(int age) { + this.age = age; + } + + @Override + public String toString() { + return "PersonPP{" + + "name='" + name + '\'' + + ", age=" + age + + '}'; + } + + public void show() { + System.out.println("show 方法"); + } + + private void showNation(String nation) { + System.out.println("我的国籍是:" + nation); + } +} diff --git a/src/thinkingInJava/learning/reflection/PersonSu.java b/src/thinkingInJava/learning/reflection/PersonSu.java new file mode 100644 index 0000000..c78a704 --- /dev/null +++ b/src/thinkingInJava/learning/reflection/PersonSu.java @@ -0,0 +1,10 @@ +package thinkingInJava.learning.reflection; + +public class PersonSu { + private E e; + + public E returnE(E e) { + System.out.println(e); + return e; + } +} diff --git a/src/thinkingInJava/learning/reflection/ReflectionTest.java b/src/thinkingInJava/learning/reflection/ReflectionTest.java new file mode 100644 index 0000000..8e213c2 --- /dev/null +++ b/src/thinkingInJava/learning/reflection/ReflectionTest.java @@ -0,0 +1,60 @@ +package thinkingInJava.learning.reflection; + +import org.junit.Test; + +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.Method; + +public class ReflectionTest { + //非反射 + @Test + public void test1() { + PersonPP personPP = new PersonPP(); + personPP.setName("asd"); + personPP.setAge(12); + + System.out.println(personPP.getAge()); + } + //反射 + @Test + public void test2() throws Exception { + //反射 + Class ppClass = PersonPP.class; + //利用反射创建实例 + PersonPP personPP = ppClass.newInstance(); + //调用属性 + Field age = ppClass.getField("age"); + age.setInt(personPP, 25); + System.out.println(age.get(personPP)); + + //调用方法 + Method show = ppClass.getMethod("show"); + show.invoke(personPP); + } + + // 利用反射调用私有方法和属性 + @Test + public void test3() throws Exception { + Class ppClass = PersonPP.class; + //调用私有构造器,创建实例 + Constructor constructor = ppClass.getDeclaredConstructor(String.class, int.class); + //设置可访问权限 + constructor.setAccessible(true); + //使用私有构造器创建实例 + PersonPP wwx = constructor.newInstance("wwx", 25); + System.out.println(wwx); + + + + //2.调用私有属性 + Field name = ppClass.getDeclaredField("name"); + name.setAccessible(true); + System.out.println(name.get(wwx)); + + //3.调用私有方法 + Method showNation = ppClass.getDeclaredMethod("showNation", String.class); + showNation.setAccessible(true); + showNation.invoke(wwx,"中国"); + } +} diff --git a/src/thinkingInJava/learning/reflection/class_/ClassTest.java b/src/thinkingInJava/learning/reflection/class_/ClassTest.java new file mode 100644 index 0000000..32380ba --- /dev/null +++ b/src/thinkingInJava/learning/reflection/class_/ClassTest.java @@ -0,0 +1,79 @@ +package thinkingInJava.learning.reflection.class_; + +import org.junit.Test; +import thinkingInJava.learning.reflection.PersonPP; + +import java.lang.reflect.Method; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; + +public class ClassTest { + @Test + public void test() throws ClassNotFoundException { + //1.类.class + Class class1 = PersonPP.class; + + //2.实例.getClass() + PersonPP personPP = new PersonPP(); + Class class2 = personPP.getClass(); + + //3.Class.forName("全类名") + Class class3 = Class.forName("thinkingInJava.learning.reflection.PersonPP"); + + //类加载器 + Class class4 = ClassLoader.getSystemClassLoader().loadClass("thinkingInJava.learning.reflection.PersonPP"); + + } + + //1.获取运行时类的父类 + @Test + public void test1() throws ClassNotFoundException, InstantiationException, IllegalAccessException { + Class clazz = Class.forName("thinkingInJava.learning.reflection.PersonPP"); + //获取父类的方法 + Class superclass = clazz.getSuperclass(); + Object o = superclass.newInstance(); + System.out.println(o); + + Method[] declaredMethods = superclass.getDeclaredMethods(); + for (Method m : declaredMethods + ) { + System.out.println(m.toString()); + } + } + + //2.获取运行时类的接口 + @Test + public void test2() throws ClassNotFoundException { + Class clazz = Class.forName("thinkingInJava.learning.reflection.PersonPP"); + + Class[] interfaces = clazz.getInterfaces(); + for (int i = 0; i < interfaces.length; i++) { + System.out.println(interfaces[i]); + } + } + + //3.获取运行时类所在包 + @Test + public void test3() throws ClassNotFoundException { + Class clazz = PersonPP.class; + Package aPackage = clazz.getPackage(); + System.out.println(aPackage); + } + //4.获取带泛型的父类 + @Test + public void test4() throws ClassNotFoundException { + Class clazz = PersonPP.class; + Type genericSuperclass = clazz.getGenericSuperclass(); + System.out.println(genericSuperclass); + } + //5.获取运行时类的父类的泛型 + @Test + public void test5() throws ClassNotFoundException { + PersonPP personPP = new PersonPP(); + Class clazz = personPP.getClass(); + Type genericSuperclass = clazz.getGenericSuperclass(); + ParameterizedType genericSuperclass1 = (ParameterizedType) genericSuperclass; + Type[] actualTypeArguments = genericSuperclass1.getActualTypeArguments(); + System.out.println(((Class)(actualTypeArguments[0])).getName()); + } +} diff --git a/src/thinkingInJava/learning/reflection/class_/UserCustomedFieldMethodETC.java b/src/thinkingInJava/learning/reflection/class_/UserCustomedFieldMethodETC.java new file mode 100644 index 0000000..cbc3108 --- /dev/null +++ b/src/thinkingInJava/learning/reflection/class_/UserCustomedFieldMethodETC.java @@ -0,0 +1,32 @@ +package thinkingInJava.learning.reflection.class_; + +import org.junit.Test; +import thinkingInJava.learning.reflection.PersonPP; + +import java.lang.reflect.Field; + +public class UserCustomedFieldMethodETC { + //调用属性 + @Test + public void test1() throws Exception { + Class clazz = PersonPP.class; + PersonPP pp = clazz.newInstance(); + //获取运行类中执行属性 + Field age = clazz.getField("age"); + //获取和设置 + age.set(pp, 27); + System.out.println(age.get(pp)); + } + + //调用私有属性 + @Test + public void test2() throws Exception { + Class clazz = Class.forName("thinkingInJava.learning.reflection.PersonPP"); + PersonPP pp = (PersonPP) clazz.newInstance(); + Field name = clazz.getDeclaredField("name"); + name.setAccessible(true); + name.set(pp, "Wwx"); + System.out.println(name.get(pp)); + + } +} diff --git a/src/thinkingInJava/learning/reflection/exer1/Exer1.java b/src/thinkingInJava/learning/reflection/exer1/Exer1.java new file mode 100644 index 0000000..fbba1a2 --- /dev/null +++ b/src/thinkingInJava/learning/reflection/exer1/Exer1.java @@ -0,0 +1,30 @@ +package thinkingInJava.learning.reflection.exer1; + +import org.junit.Test; + +import java.io.*; +import java.util.Properties; + +public class Exer1 { + @Test + public void propertiesTest() throws IOException { + Properties properties = new Properties(); + FileInputStream fileInputStream = new FileInputStream(new File("src/thinkingInJava/learning/reflection/exer1/info.properties")); + + properties.load(fileInputStream); + String host = properties.getProperty("host"); + String port = properties.getProperty("port"); + System.out.println("/"+host+":"+port); + } + + @Test + public void classLoaderTest() throws IOException { + Properties properties = new Properties(); + //通过类加载器读取文件的默认路径为:src下 + InputStream inputStream = ClassLoader.getSystemClassLoader().getResourceAsStream("infoClassLoaderTest.properties"); + properties.load(inputStream); + String host = properties.getProperty("host"); + String port = properties.getProperty("port"); + System.out.println("/"+host+":"+port); + } +} diff --git a/src/thinkingInJava/learning/reflection/exer1/info.properties b/src/thinkingInJava/learning/reflection/exer1/info.properties new file mode 100644 index 0000000..71f4897 --- /dev/null +++ b/src/thinkingInJava/learning/reflection/exer1/info.properties @@ -0,0 +1,2 @@ +host=127.0.0.1 +port=8989 \ No newline at end of file diff --git a/src/thinkingInJava/learning/reflection/exer2/Apple.java b/src/thinkingInJava/learning/reflection/exer2/Apple.java new file mode 100644 index 0000000..540c055 --- /dev/null +++ b/src/thinkingInJava/learning/reflection/exer2/Apple.java @@ -0,0 +1,8 @@ +package thinkingInJava.learning.reflection.exer2; + +public class Apple implements Fruit{ + @Override + public void squeeze() { + System.out.println("榨苹果汁"); + } +} diff --git a/src/thinkingInJava/learning/reflection/exer2/Banana.java b/src/thinkingInJava/learning/reflection/exer2/Banana.java new file mode 100644 index 0000000..d2f06c2 --- /dev/null +++ b/src/thinkingInJava/learning/reflection/exer2/Banana.java @@ -0,0 +1,8 @@ +package thinkingInJava.learning.reflection.exer2; + +public class Banana implements Fruit{ + @Override + public void squeeze() { + System.out.println("榨香蕉汁"); + } +} diff --git a/src/thinkingInJava/learning/reflection/exer2/Exer2.java b/src/thinkingInJava/learning/reflection/exer2/Exer2.java new file mode 100644 index 0000000..92aa69e --- /dev/null +++ b/src/thinkingInJava/learning/reflection/exer2/Exer2.java @@ -0,0 +1,47 @@ +package thinkingInJava.learning.reflection.exer2; + +import org.junit.Test; + +import java.io.IOException; +import java.io.InputStream; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.Properties; + +public class Exer2 { + @Test + public void test() { + try { + //读取配置文件 + Properties properties = new Properties(); + InputStream is = ClassLoader.getSystemClassLoader().getResourceAsStream("fruit-config.properties"); + properties.load(is); + //获取全类名 + String appleName = properties.getProperty("AppleName"); + String bananaName = properties.getProperty("BananaName"); + String orangeName = properties.getProperty("OrangeName"); + //利用反射创建对象 + Class appleClass = Class.forName(appleName); + Class bananaClass = Class.forName(bananaName); + Class orangeClass = Class.forName(orangeName); + //创建实例 + Constructor appleConstructor = appleClass.getDeclaredConstructor(); + Constructor bananaConstructor = bananaClass.getDeclaredConstructor(); + Constructor orangeConstructor = orangeClass.getDeclaredConstructor(); + Apple apple = (Apple) appleConstructor.newInstance(); + Banana banana = (Banana) bananaConstructor.newInstance(); + Orange orange = (Orange) orangeConstructor.newInstance(); + //创建榨汁机实例及方法 + Class jucierClass = Class.forName("thinkingInJava.learning.reflection.exer2.Juicer"); + Juicer juicer = (Juicer) jucierClass.newInstance(); + Method method = jucierClass.getMethod("run", Fruit.class); + + method.invoke(juicer, apple); + method.invoke(juicer, banana); + method.invoke(juicer, orange); + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/src/thinkingInJava/learning/reflection/exer2/Fruit.java b/src/thinkingInJava/learning/reflection/exer2/Fruit.java new file mode 100644 index 0000000..1b9f6cb --- /dev/null +++ b/src/thinkingInJava/learning/reflection/exer2/Fruit.java @@ -0,0 +1,5 @@ +package thinkingInJava.learning.reflection.exer2; + +public interface Fruit { + void squeeze(); +} diff --git a/src/thinkingInJava/learning/reflection/exer2/Juicer.java b/src/thinkingInJava/learning/reflection/exer2/Juicer.java new file mode 100644 index 0000000..93df2ce --- /dev/null +++ b/src/thinkingInJava/learning/reflection/exer2/Juicer.java @@ -0,0 +1,7 @@ +package thinkingInJava.learning.reflection.exer2; + +public class Juicer { + public void run(Fruit fruit) { + fruit.squeeze(); + } +} diff --git a/src/thinkingInJava/learning/reflection/exer2/Orange.java b/src/thinkingInJava/learning/reflection/exer2/Orange.java new file mode 100644 index 0000000..4ad4a05 --- /dev/null +++ b/src/thinkingInJava/learning/reflection/exer2/Orange.java @@ -0,0 +1,9 @@ +package thinkingInJava.learning.reflection.exer2; + +public class Orange implements Fruit { + + @Override + public void squeeze() { + System.out.println("榨橘子汁"); + } +} diff --git a/src/thinkingInJava/learning/reflection/exer2/img.png b/src/thinkingInJava/learning/reflection/exer2/img.png new file mode 100644 index 0000000..6f4959c Binary files /dev/null and b/src/thinkingInJava/learning/reflection/exer2/img.png differ