diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..073a3df
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Datasource local storage ignored files
+/../../../../:\Projects\JavaStudy\.idea/dataSources/
+/dataSources.local.xml
+# Editor-based HTTP Client requests
+/httpRequests/
diff --git a/.idea/libraries/c3p0_0_9_5_2.xml b/.idea/libraries/c3p0_0_9_5_2.xml
new file mode 100644
index 0000000..974e018
--- /dev/null
+++ b/.idea/libraries/c3p0_0_9_5_2.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/druid_1_0_9.xml b/.idea/libraries/druid_1_0_9.xml
new file mode 100644
index 0000000..dde30e5
--- /dev/null
+++ b/.idea/libraries/druid_1_0_9.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/mchange_commons_java_0_2_12.xml b/.idea/libraries/mchange_commons_java_0_2_12.xml
new file mode 100644
index 0000000..d6f4d5d
--- /dev/null
+++ b/.idea/libraries/mchange_commons_java_0_2_12.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/mysql_connector_java_5_1_37_bin.xml b/.idea/libraries/mysql_connector_java_5_1_37_bin.xml
new file mode 100644
index 0000000..4ae0472
--- /dev/null
+++ b/.idea/libraries/mysql_connector_java_5_1_37_bin.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/mysql_connector_java_5_1_37_bin__2_.xml b/.idea/libraries/mysql_connector_java_5_1_37_bin__2_.xml
new file mode 100644
index 0000000..fbb7cf7
--- /dev/null
+++ b/.idea/libraries/mysql_connector_java_5_1_37_bin__2_.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..d104aba
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..f8503b5
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml
new file mode 100644
index 0000000..e96534f
--- /dev/null
+++ b/.idea/uiDesigner.xml
@@ -0,0 +1,124 @@
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..5fc0921
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/README.md b/README.md
deleted file mode 100644
index 663d6f0..0000000
--- a/README.md
+++ /dev/null
@@ -1,2 +0,0 @@
-# JavaStudy
-学习java 的资料
diff --git a/a.txt b/a.txt
new file mode 100644
index 0000000..8c95eea
--- /dev/null
+++ b/a.txt
@@ -0,0 +1 @@
+贾国胜2020年11月16日学会了git
diff --git a/bug.txt b/bug.txt
new file mode 100644
index 0000000..ee9c132
--- /dev/null
+++ b/bug.txt
@@ -0,0 +1,9 @@
+div 方法出异常了
+异常的名称:ArithmeticException
+异常的原因:/ by zero
+--------------------------
+add 方法出异常了
+异常的名称:NullPointerException
+异常的原因:null
+--------------------------
+本次测试一共出现 2 次异常
\ No newline at end of file
diff --git a/gbk.txt b/gbk.txt
new file mode 100644
index 0000000..b194a82
--- /dev/null
+++ b/gbk.txt
@@ -0,0 +1 @@
+gbk����
\ No newline at end of file
diff --git a/index-files/index-1.html b/index-files/index-1.html
new file mode 100644
index 0000000..e10e717
--- /dev/null
+++ b/index-files/index-1.html
@@ -0,0 +1,128 @@
+
+
+
+
+
+
+H - 索引
+
+
+
+
+
+
+
+
您的浏览器已禁用 JavaScript。
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/index-files/index-2.html b/index-files/index-2.html
new file mode 100644
index 0000000..692dd21
--- /dev/null
+++ b/index-files/index-2.html
@@ -0,0 +1,126 @@
+
+
+
+
+
+
+M - 索引
+
+
+
+
+
+
+
+您的浏览器已禁用 JavaScript。
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/out.txt b/out.txt
new file mode 100644
index 0000000..3129bb2
Binary files /dev/null and b/out.txt differ
diff --git "a/out/production/351円253円230円347円272円247円350円257円255円346円263円225円/druid.properties" "b/out/production/351円253円230円347円272円247円350円257円255円346円263円225円/druid.properties"
new file mode 100644
index 0000000..913a566
--- /dev/null
+++ "b/out/production/351円253円230円347円272円247円350円257円255円346円263円225円/druid.properties"
@@ -0,0 +1,7 @@
+driverClassName=com.mysql.jdbc.Driver
+url=jdbc:mysql://127.0.0.1:3306/db3?useUnicode=true&characterEncoding=utf8
+username=root
+password=jiags1997
+initialSize=5
+maxActive=10
+maxWait=3000
\ No newline at end of file
diff --git a/out_test.txt b/out_test.txt
new file mode 100644
index 0000000..12e1fb7
Binary files /dev/null and b/out_test.txt differ
diff --git "a/out_345円207円272円345円270円210円350円241円250円.txt" "b/out_345円207円272円345円270円210円350円241円250円.txt"
new file mode 100644
index 0000000..8dd0cad
--- /dev/null
+++ "b/out_345円207円272円345円270円210円350円241円250円.txt"
@@ -0,0 +1,9 @@
+1.先帝创业未半而中道崩殂,今天下三分,益州疲弊,此诚危急存亡之秋也。然侍卫之臣不懈于内,忠志之士忘身于外者,盖追先帝之殊遇,欲报之于陛下也。诚宜开张圣听,以光先帝遗德,恢弘志士之气,不宜妄自菲薄,引喻失义,以塞忠谏之路也。
+2.宫中府中,俱为一体,陟罚臧否,不宜异同。若有作奸犯科及为忠善者,宜付有司论其刑赏,以昭陛下平明之理,不宜偏私,使内外异法也。
+3.侍中、侍郎郭攸之、费祎、董允等,此皆良实,志虑忠纯,是以先帝简拔以遗陛下。愚以为宫中之事,事无大小,悉以咨之,然后施行,必得裨补阙漏,有所广益。
+4.将军向宠,性行淑均,晓畅军事,试用之于昔日,先帝称之曰能,是以众议举宠为督。愚以为营中之事,悉以咨之,必能使行阵和睦,优劣得所。
+5.亲贤臣,远小人,此先汉所以兴隆也;亲小人,远贤臣,此后汉所以倾颓也。先帝在时,每与臣论此事,未尝不叹息痛恨于桓、灵也。侍中、尚书、长史、参军,此悉贞良死节之臣,愿陛下亲之信之,则汉室之隆,可计日而待也。
+6.臣本布衣,躬耕于南阳,苟全性命于乱世,不求闻达于诸侯。先帝不以臣卑鄙,猥自枉屈,三顾臣于草庐之中,咨臣以当世之事,由是感激,遂许先帝以驱驰。后值倾覆,受任于败军之际,奉命于危难之间,尔来二十有一年矣。
+7.先帝知臣谨慎,故临崩寄臣以大事也。受命以来,夙夜忧叹,恐付托不效,以伤先帝之明,故五月渡泸,深入不毛。今南方已定,兵甲已足,当奖率三军,北定中原,庶竭驽钝,攘除奸凶,兴复汉室,还于旧都。此臣所以报先帝而忠陛下之职分也。至于斟酌损益,进尽忠言,则攸之、祎、允之任也。
+8.愿陛下托臣以讨贼兴复之效,不效,则治臣之罪,以告先帝之灵。若无兴德之言,则责攸之、祎、允等之慢,以彰其咎;陛下亦宜自谋,以咨诹善道,察纳雅言,深追先帝遗诏,臣不胜受恩感激。
+9.今当远离,临表涕零,不知所言。
diff --git a/tcpserver.txt b/tcpserver.txt
new file mode 100644
index 0000000..e240297
--- /dev/null
+++ b/tcpserver.txt
@@ -0,0 +1,9 @@
+3.侍中、侍郎郭攸之、费祎、董允等,此皆良实,志虑忠纯,是以先帝简拔以遗陛下。愚以为宫中之事,事无大小,悉以咨之,然后施行,必得裨补阙漏,有所广益。
+8.愿陛下托臣以讨贼兴复之效,不效,则治臣之罪,以告先帝之灵。若无兴德之言,则责攸之、祎、允等之慢,以彰其咎;陛下亦宜自谋,以咨诹善道,察纳雅言,深追先帝遗诏,臣不胜受恩感激。
+4.将军向宠,性行淑均,晓畅军事,试用之于昔日,先帝称之曰能,是以众议举宠为督。愚以为营中之事,悉以咨之,必能使行阵和睦,优劣得所。
+2.宫中府中,俱为一体,陟罚臧否,不宜异同。若有作奸犯科及为忠善者,宜付有司论其刑赏,以昭陛下平明之理,不宜偏私,使内外异法也。
+1.先帝创业未半而中道崩殂,今天下三分,益州疲弊,此诚危急存亡之秋也。然侍卫之臣不懈于内,忠志之士忘身于外者,盖追先帝之殊遇,欲报之于陛下也。诚宜开张圣听,以光先帝遗德,恢弘志士之气,不宜妄自菲薄,引喻失义,以塞忠谏之路也。
+9.今当远离,临表涕零,不知所言。
+6.臣本布衣,躬耕于南阳,苟全性命于乱世,不求闻达于诸侯。先帝不以臣卑鄙,猥自枉屈,三顾臣于草庐之中,咨臣以当世之事,由是感激,遂许先帝以驱驰。后值倾覆,受任于败军之际,奉命于危难之间,尔来二十有一年矣。
+7.先帝知臣谨慎,故临崩寄臣以大事也。受命以来,夙夜忧叹,恐付托不效,以伤先帝之明,故五月渡泸,深入不毛。今南方已定,兵甲已足,当奖率三军,北定中原,庶竭驽钝,攘除奸凶,兴复汉室,还于旧都。此臣所以报先帝而忠陛下之职分也。至于斟酌损益,进尽忠言,则攸之、祎、允之任也。
+5.亲贤臣,远小人,此先汉所以兴隆也;亲小人,远贤臣,此后汉所以倾颓也。先帝在时,每与臣论此事,未尝不叹息痛恨于桓、灵也。侍中、尚书、长史、参军,此悉贞良死节之臣,愿陛下亲之信之,则汉室之隆,可计日而待也。
\ No newline at end of file
diff --git a/utf_8.txt b/utf_8.txt
new file mode 100644
index 0000000..f3ca610
--- /dev/null
+++ b/utf_8.txt
@@ -0,0 +1 @@
+你好
\ No newline at end of file
diff --git "a/344円270円255円345円233円275円350円256円241円347円256円227円346円234円272円345円255円246円344円274円232円346円216円250円350円215円220円345円233円275円351円231円205円345円255円246円346円234円257円344円274円232円350円256円256円345円222円214円346円234円237円345円210円212円347円233円256円345円275円225円-2019.pdf" "b/344円270円255円345円233円275円350円256円241円347円256円227円346円234円272円345円255円246円344円274円232円346円216円250円350円215円220円345円233円275円351円231円205円345円255円246円346円234円257円344円274円232円350円256円256円345円222円214円346円234円237円345円210円212円347円233円256円345円275円225円-2019.pdf"
deleted file mode 100644
index 78a4ed5..0000000
Binary files "a/344円270円255円345円233円275円350円256円241円347円256円227円346円234円272円345円255円246円344円274円232円346円216円250円350円215円220円345円233円275円351円231円205円345円255円246円346円234円257円344円274円232円350円256円256円345円222円214円346円234円237円345円210円212円347円233円256円345円275円225円-2019.pdf" and /dev/null differ
diff --git "a/345円207円272円345円270円210円350円241円250円.txt" "b/345円207円272円345円270円210円350円241円250円.txt"
new file mode 100644
index 0000000..e240297
--- /dev/null
+++ "b/345円207円272円345円270円210円350円241円250円.txt"
@@ -0,0 +1,9 @@
+3.侍中、侍郎郭攸之、费祎、董允等,此皆良实,志虑忠纯,是以先帝简拔以遗陛下。愚以为宫中之事,事无大小,悉以咨之,然后施行,必得裨补阙漏,有所广益。
+8.愿陛下托臣以讨贼兴复之效,不效,则治臣之罪,以告先帝之灵。若无兴德之言,则责攸之、祎、允等之慢,以彰其咎;陛下亦宜自谋,以咨诹善道,察纳雅言,深追先帝遗诏,臣不胜受恩感激。
+4.将军向宠,性行淑均,晓畅军事,试用之于昔日,先帝称之曰能,是以众议举宠为督。愚以为营中之事,悉以咨之,必能使行阵和睦,优劣得所。
+2.宫中府中,俱为一体,陟罚臧否,不宜异同。若有作奸犯科及为忠善者,宜付有司论其刑赏,以昭陛下平明之理,不宜偏私,使内外异法也。
+1.先帝创业未半而中道崩殂,今天下三分,益州疲弊,此诚危急存亡之秋也。然侍卫之臣不懈于内,忠志之士忘身于外者,盖追先帝之殊遇,欲报之于陛下也。诚宜开张圣听,以光先帝遗德,恢弘志士之气,不宜妄自菲薄,引喻失义,以塞忠谏之路也。
+9.今当远离,临表涕零,不知所言。
+6.臣本布衣,躬耕于南阳,苟全性命于乱世,不求闻达于诸侯。先帝不以臣卑鄙,猥自枉屈,三顾臣于草庐之中,咨臣以当世之事,由是感激,遂许先帝以驱驰。后值倾覆,受任于败军之际,奉命于危难之间,尔来二十有一年矣。
+7.先帝知臣谨慎,故临崩寄臣以大事也。受命以来,夙夜忧叹,恐付托不效,以伤先帝之明,故五月渡泸,深入不毛。今南方已定,兵甲已足,当奖率三军,北定中原,庶竭驽钝,攘除奸凶,兴复汉室,还于旧都。此臣所以报先帝而忠陛下之职分也。至于斟酌损益,进尽忠言,则攸之、祎、允之任也。
+5.亲贤臣,远小人,此先汉所以兴隆也;亲小人,远贤臣,此后汉所以倾颓也。先帝在时,每与臣论此事,未尝不叹息痛恨于桓、灵也。侍中、尚书、长史、参军,此悉贞良死节之臣,愿陛下亲之信之,则汉室之隆,可计日而待也。
\ No newline at end of file
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/Demo01/demo01.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/Demo01/demo01.java"
new file mode 100644
index 0000000..a1fc494
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/Demo01/demo01.java"
@@ -0,0 +1,39 @@
+package Demo01;
+
+import java.util.*;
+
+public class demo01 {
+ public static void main(String[] args) {
+ for(int i=1;i<10;i++) + { + for(int j=1;j<=i;j++) + { + System.out.print(j+"*"+i+"="+j*i+'\t'); + } + System.out.println(); + + } + int[] a; + a = new int[] { 18, 62, 68, 82, 65, 9 }; + String content = Arrays.toString(a); + System.out.println(content); + Scanner in=new Scanner(System.in); + List list=new ArrayList(); + list.add("A"); + list.add("B"); + + //list.add(100); + //1.当我们将一个对象放入集合中,集合不会记住此对象的类型,当再次从集合中取出此对象时,改对象的编译类型变成了Object类型,但其运行时类型任然为其本身类型。 + //2.因此,//1处取出集合元素时需要人为的强制类型转化到具体的目标类型,且很容易出现"java.lang.ClassCastException"异常。 + for (int i = 0; i < list.size(); i++) { +// System.out.println(list.get(i)); + String value= (String) list.get(i); + System.out.println(value); + } + + + + + + } +} diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/Demo18IO/IOTest/1.jpg" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/Demo18IO/IOTest/1.jpg" new file mode 100644 index 0000000..1e4f78a Binary files /dev/null and "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/Demo18IO/IOTest/1.jpg" differ diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/Demo18IO/IOTest/IOTets.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/Demo18IO/IOTest/IOTets.java" new file mode 100644 index 0000000..49d0a39 --- /dev/null +++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/Demo18IO/IOTest/IOTets.java" @@ -0,0 +1,20 @@ +package Demo18IO.IOTest; + +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; + +public class IOTets { + public static void main(String[] args) throws IOException { + FileInputStream fis=new FileInputStream("F:\\JavaStudy\\基础语法\\src\\Demo18IO\\IOTest\\你的名字.jpg"); + FileOutputStream fos=new FileOutputStream("F:\\JavaStudy\\基础语法\\src\\Demo18IO\\IOTest\1円.jpg"); + byte [] b=new byte[1024]; + int len; + while((len=fis.read(b))!=-1){ + fos.write(b,0,len); + + } + fos.close(); + fis.close(); + } +} diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/Demo18IO/IOTest/344円275円240円347円232円204円345円220円215円345円255円227円.jpg" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/Demo18IO/IOTest/344円275円240円347円232円204円345円220円215円345円255円227円.jpg" new file mode 100644 index 0000000..1e4f78a Binary files /dev/null and "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/Demo18IO/IOTest/344円275円240円347円232円204円345円220円215円345円255円227円.jpg" differ diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/Demo18IO/InputStream/inputStreamTest.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/Demo18IO/InputStream/inputStreamTest.java" new file mode 100644 index 0000000..34136d2 --- /dev/null +++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/Demo18IO/InputStream/inputStreamTest.java" @@ -0,0 +1,29 @@ +package Demo18IO.InputStream; + +import java.io.FileInputStream; +import java.io.IOException; + +/* + + */ +public class inputStreamTest { + public static void main(String[] args) throws IOException { + String filepath="F:\\JavaStudy\\基础语法\\src\\Demo18IO\\OutputStream\\b.txt"; + FileInputStream fis=new FileInputStream(filepath); +// int read=fis.read(); +// System.out.println((char)read); +// int b; //read()方法:每次可以读取一个字节的数据,提升为int类型,读取到文件末尾,返回`-1` +// while((b=fis.read())!=-1){ +// System.out.println((char)b); +// } + + byte [] b=new byte[2]; + int len=fis.read(b); + while((len=fis.read(b))!=-1){ + System.out.println(new String(b)); + } + + fis.close(); + + } +} diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/Demo18IO/OutputStream/OutputstreamTest.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/Demo18IO/OutputStream/OutputstreamTest.java" new file mode 100644 index 0000000..1ba598e --- /dev/null +++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/Demo18IO/OutputStream/OutputstreamTest.java" @@ -0,0 +1,39 @@ +package Demo18IO.OutputStream; + +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.Arrays; + +/* + 字节输出流【OutputStream】 + java.io.OutputStream 抽象类是表示字节输出流的所有类的超类,将指定的字节信息写出到目的地。它定义了字节输出流的基本共性功能方法。 +* public void close():关闭此输出流并释放与此流相关联的任何系统资源。 +* public void flush():刷新此输出流并强制任何缓冲的输出字节被写出。 +* public void write(byte[] b):将 b.length字节从指定的字节数组写入此输出流。 +* public void write(byte[] b, int off, int len):从指定的字节数组写入 len字节,从偏移量 off开始输出到此输出流。 +* public abstract void write(int b):将指定的字节输出流。 + OutputStream有很多子类,我们从最简单的一个子类开始。 + java.io.FileOutputStream `类是文件输出流,用于将数据从内存写出到文件。 + 构造方法: + * public FileOutputStream(File file)`:创建文件输出流以写入由指定的 File对象表示的文件。 + * public FileOutputStream(String name)`: 创建文件输出流以指定的名称写入文件。 + + */ +public class OutputstreamTest { + public static void main(String[] args) throws IOException { + //一次写一个字节 + String filepath="F:\\JavaStudy\\基础语法\\src\\Demo18IO\\OutputStream\\a.txt"; + FileOutputStream fos=new FileOutputStream(filepath); + fos.write(97); + fos.close(); + FileOutputStream fos2=new FileOutputStream(filepath,true); + byte[] b={100,102,112}; + byte[] c="hinata".getBytes(); + System.out.println(Arrays.toString(c));//返回数组的字符串表现形式 + fos2.write(b,0,1); + fos2.write(c); + fos2.close(); + + + } +} diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/Demo18IO/OutputStream/a.txt" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/Demo18IO/OutputStream/a.txt" new file mode 100644 index 0000000..ce6779b --- /dev/null +++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/Demo18IO/OutputStream/a.txt" @@ -0,0 +1 @@ +adhinata \ No newline at end of file diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/Demo18IO/OutputStream/b.txt" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/Demo18IO/OutputStream/b.txt" new file mode 100644 index 0000000..402476b --- /dev/null +++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/Demo18IO/OutputStream/b.txt" @@ -0,0 +1 @@ +ABCDE \ No newline at end of file diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/Demo18IO/Reader/FileReaderTest.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/Demo18IO/Reader/FileReaderTest.java" new file mode 100644 index 0000000..952fc07 --- /dev/null +++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/Demo18IO/Reader/FileReaderTest.java" @@ -0,0 +1,27 @@ +package Demo18IO.Reader; + +import java.io.FileReader; +import java.io.IOException; + +/* + FileReader 文件字符输入流 + 作用:把硬盘的而文件以字符的形式读取到内存中 + + 字符输入流的使用步骤: + 1.创建FIleReader对象,构造方法中绑定要读取的数据 + 2.使用FileReader对象read()方法读取文件 + 3.释放资源 + */ +public class FileReaderTest { + public static void main(String[] args) throws IOException { + FileReader fr=new FileReader("F:\\JavaStudy\\基础语法\\src\\Demo18IO\\Reader\\a.txt"); + int len;//read()方法 + len=fr.read(); + System.out.print((char)len); + while((len=fr.read())!=-1){ + System.out.println((char)len); + } + fr.close(); + + } +} diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/Demo18IO/Reader/a.txt" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/Demo18IO/Reader/a.txt" new file mode 100644 index 0000000..aede612 --- /dev/null +++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/Demo18IO/Reader/a.txt" @@ -0,0 +1 @@ +张资卿卿 \ No newline at end of file diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/Demo18IO/Writer/WriterTest.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/Demo18IO/Writer/WriterTest.java" new file mode 100644 index 0000000..a349d92 --- /dev/null +++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/Demo18IO/Writer/WriterTest.java" @@ -0,0 +1,16 @@ +package Demo18IO.Writer; + +import java.io.FileWriter; +import java.io.IOException; + +public class WriterTest { + public static void main(String[] args) throws IOException { + FileWriter fw=new FileWriter("F:\\JavaStudy\\基础语法\\src\\Demo18IO\\Reader\\a.txt"); + char []c={'张','资','卿'}; + fw.write(c); + fw.flush(); + fw.write("卿"); + fw.flush(); + fw.close(); + } +} diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/Demo22Socket/Solution.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/Demo22Socket/Solution.java" new file mode 100644 index 0000000..114efbd --- /dev/null +++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/Demo22Socket/Solution.java" @@ -0,0 +1,33 @@ +package Demo22Socket; + +import java.util.Scanner; + +public class Solution { + public static void main(String[] args) { + int num; + num=new Scanner(System.in).nextInt(); + System.out.println(reverse(num)); + } + public static int reverse(int x){ + int sign=-1; + int num=0; + int r=0; + if(x<0){ + x=sign*x; + sign=1; + } + while(x!=0){ + r=x%10; + x=x/10; + num=num*10+r; + } + if(sign<0&&num<=integer.max_value) + { + return num; + } + if(sign>0&&num<=(integer.max_value+1)){ + return -1*num; + } + return 0; + } +} diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/Demo22Socket/TCPClient.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/Demo22Socket/TCPClient.java" new file mode 100644 index 0000000..f2ad058 --- /dev/null +++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/Demo22Socket/TCPClient.java" @@ -0,0 +1,52 @@ +package Demo22Socket; +/* + tcp通信客户端,向服务器发送连接请求, 给服务器发送数据,读取服务器回写数据 + 表示客户端的类 + java.net.Socket:此类实现客户端套接字,套接字是两台计算机通信的端点 + 套接字=ip地址+端口号 + 构造方法: + Socket(String host,int port)创建一个流套接字并将其连接到指定的主机上的指定端口号 + 参数: + String host:String host:服务器主机名称/主机IP地址 + int part:服务器端口号 + 成员方法: + OutputStream getOutputStream()返回此套接字的输出流。 + InputStream getInputStream() 返回此套接字的输入流。 + void close() 关闭此套接字。 + + 实现步骤: + 1.创建一个客户端对象Socket,构造方法绑定服务器的IP地址和端口号 + 2.使用Socket对象中的方法getOutputStream()获取网络字节输出流OutputStream对象 + 3.使用网络字节输出流OutputStream对象中的方法write,给服务器发送数据 + 4.使用Socket对象中的方法getInputStream()获取网络字节输入流InputStream对象 + 5.使用网络字节输入流InputStream对象中的方法read,读取服务器回写的数据 + 6.释放资源(Socket) + 注意: + 1.客户端和服务器端进行交互,必须使用Socket中提供的网络流,不能使用自己创建的流对象 + 2.当我们创建客户端对象Socket的时候,就会去请求服务器和服务器经过3次握手建立连接通路 + 这时如果服务器没有启动,那么就会抛出异常ConnectException: Connection refused: connect + 如果服务器已经启动,那么就可以进行交互了 + */ + +import java.io.*; +import java.net.Socket; + +public class TCPClient { + public static void main(String[] args) throws IOException { + FileInputStream fis=new FileInputStream("出师表.txt"); + Socket socket=new Socket("127.0.0.1",8888); + OutputStream os=socket.getOutputStream(); + byte [] b=new byte [1024]; + int len=0; + while((len=fis.read(b))!=-1){ + os.write(b,0,len); + } + socket.shutdownOutput();// + InputStream is=socket.getInputStream(); + while((len=is.read(b))!=-1){ + System.out.println(new String(b,0,len)); + } + fis.close(); + socket.close(); + } +} diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/Demo22Socket/TcpServer.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/Demo22Socket/TcpServer.java" new file mode 100644 index 0000000..d940049 --- /dev/null +++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/Demo22Socket/TcpServer.java" @@ -0,0 +1,51 @@ +package Demo22Socket; + +import java.io.*; +import java.net.ServerSocket; +import java.net.Socket; + +/* + TCP通信的服务器端:接收客户端的请求,读取客户端发送的数据,给客户端回写数据 + 表示服务器的类: + java.net.ServerSocket:此类实现服务器套接字。 + + 构造方法: + ServerSocket(int port) 创建绑定到特定端口的服务器套接字。 + + 服务器端必须明确一件事情,必须的知道是哪个客户端请求的服务器 + 所以可以使用accept方法获取到请求的客户端对象Socket + 成员方法: + Socket accept() 侦听并接受到此套接字的连接。 + + 服务器的实现步骤: + 1.创建服务器ServerSocket对象和系统要指定的端口号 + 2.使用ServerSocket对象中的方法accept,获取到请求的客户端对象Socket + 3.使用Socket对象中的方法getInputStream()获取网络字节输入流InputStream对象 + 4.使用网络字节输入流InputStream对象中的方法read,读取客户端发送的数据 + 5.使用Socket对象中的方法getOutputStream()获取网络字节输出流OutputStream对象 + 6.使用网络字节输出流OutputStream对象中的方法write,给客户端回写数据 + 7.释放资源(Socket,ServerSocket) + */ +public interface TcpServer { + public static void main(String[] args) throws IOException { + File file=new File("tcpserver.txt"); + if(!file.exists()){ + file.createNewFile(); + } + ServerSocket serverSocket=new ServerSocket(8888); + FileOutputStream fos=new FileOutputStream(file); + Socket socket=serverSocket.accept(); + InputStream is=socket.getInputStream(); + byte [] b=new byte[1024]; + int len=0; + while((len=is.read(b))!=-1){ + fos.write(b,0,len); + } + OutputStream os=socket.getOutputStream(); + os.write("文件上传成功!".getBytes()); + fos.close(); + socket.close(); + serverSocket.close(); + + } +} diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/Leetcode/Day01.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/Leetcode/Day01.java" new file mode 100644 index 0000000..47a665b --- /dev/null +++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/Leetcode/Day01.java" @@ -0,0 +1,76 @@ +package Leetcode; + +import java.util.*; +/* + 学到的!!! + Arrays.copyOfRange(T[ ] original,int from,int to) + 将一个原始的数组original,从下标from开始复制,复制到上标to,生成一个新的数组。 + 注意这里包括下标from,不包括上标to。 + */ +public class Day01 { + + public static void main(String[] args) { + int[][] points = new int[][]{{3, 3}, {-2, 4}, {5, -1}}; + int K = 2; + + int[][] ans = kClosest(points, K); + for (int i = 0; i < K; i++) { + System.out.println(Arrays.toString(ans[i])); + + } + } + + /* + public static int[][] kClosest(int[][] points, int K) { + List list = new ArrayList();
+ int [][]ans=new int[K][];
+ for (int i = 0; i < points.length; i++) { + list.add(points[i]); + } + Collections.sort(list, new Comparator() {
+ @Override
+ public int compare(int[] o1, int[] o2) {
+ return (int) ((Math.pow(o1[0],2)+Math.pow(o1[1],2))-(Math.pow(o2[0],2 )+Math.pow(o2[1],2)));
+ }
+ });
+ for (int i = 0; i pq = new PriorityQueue(new Comparator() {
+ @Override
+ public int compare(int[] o1, int[] o2) {
+ return o2[0] - o1[0];
+ }
+ });
+ //把point的欧氏距离的平方在原来数组的位置存入优先队列中,
+ for (int i = 0; i < K; i++) { + pq.offer(new int[]{points[i][0] * points[i][0] + points[i][1] * points[i][1], i}); + } + for(int i=K;i list =new ArrayList();
+ ListNode p=head;
+ while(p!=null){
+ list.add(p.val);
+ p=p.next;
+ }
+ Collections.sort(list);
+ ListNode r=head;
+ for(Integer value:list){
+ r.val=value;
+ r=r.next;
+ }
+ r=null;
+ return head;
+
+ */
+ //插入排序方式
+ ListNode dummy = new ListNode(0), pre;
+ dummy.next = head;
+
+ while(head != null && head.next != null) {
+// if(head.val <= head.next.val) { +// head = head.next; +// } + pre = dummy; + + while (pre.next.val < head.next.val) pre = pre.next; + + ListNode curr = head.next; + head.next = curr.next; + curr.next = pre.next; + pre.next = curr; + } + return dummy.next; + } + public static void main(String[] args) { + int []arr={4,2,1,3}; + ListNode head=new ListNode(arr[0]); + + ListNode p=head; + + for (int i=1;i arr1[1]>arr2[1] ?1:-1); //按照区间右端点排序
+ for (int [] a:points
+ ) {
+ System.out.println(a[1]);
+
+ }
+
+ int last=points[0][1];//第一个区间最右边的位置赋给last
+ for(int i=1;i0&&(-1*num)>Integer.MIN_VALUE){
+ return (int)(-1*num);
+ }
+ return 0;
+ }
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo02/Person.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo02/Person.java"
new file mode 100644
index 0000000..db3d697
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo02/Person.java"
@@ -0,0 +1,19 @@
+package demo02;
+
+public class Person {
+ private String name;
+ private int age;
+ private String sex;
+ public Person()
+ {
+ System.out.println("我被调用啦!");
+ }
+ public String getName()
+ {
+ return this.name;
+ }
+ public void setName(String name)
+ {
+ this.name=name;
+ }
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo02/Test.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo02/Test.java"
new file mode 100644
index 0000000..8763960
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo02/Test.java"
@@ -0,0 +1,29 @@
+package demo02;
+
+import java.util.Scanner;
+
+public class Test {
+ public static void main(String[] args) {
+ /*
+ Person person=new Person();
+ person.setName("贾国胜");
+ System.out.println(person.getName());
+
+ */
+ methoParam(new Scanner(System.in));
+ Scanner sc=methoParam();
+ int num=sc.nextInt();
+ System.out.println("输入的是:"+num);
+
+ }
+ public static void methoParam(Scanner sc)
+ {
+ int num=sc.nextInt();
+ System.out.println("输入的数字是:"+num);
+ }
+ public static Scanner methoParam()
+ {
+ return new Scanner(System.in);
+ }
+
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo03/Father.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo03/Father.java"
new file mode 100644
index 0000000..8950ceb
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo03/Father.java"
@@ -0,0 +1,12 @@
+package demo03;
+
+public class Father {
+ public Father()
+ {
+ System.out.println("父类构造");
+ }
+ public Father(int num)
+ {
+ System.out.println("父类重载构造");
+ }
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo03/Son.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo03/Son.java"
new file mode 100644
index 0000000..4771f51
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo03/Son.java"
@@ -0,0 +1,10 @@
+package demo03;
+
+public class Son extends Father{
+ public Son()
+ {
+ super(10);
+ System.out.println("子类构造");
+
+ }
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo03/Test.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo03/Test.java"
new file mode 100644
index 0000000..3a55568
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo03/Test.java"
@@ -0,0 +1,9 @@
+package demo03;
+
+public class Test {
+ public static void main(String[] args) {
+ Son son=new Son();
+ }
+
+
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo04/Child.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo04/Child.java"
new file mode 100644
index 0000000..f47a6c2
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo04/Child.java"
@@ -0,0 +1,9 @@
+package demo04;
+
+public class Child extends Son {
+ public Child()
+ {
+
+ super.study();
+ }
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo04/Father.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo04/Father.java"
new file mode 100644
index 0000000..06f5c9c
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo04/Father.java"
@@ -0,0 +1,8 @@
+package demo04;
+//抽象
+public abstract class Father {
+ public Father(){
+ System.out.println("父类构造方法被调用");
+ }
+ public abstract void study();
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo04/Grandson.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo04/Grandson.java"
new file mode 100644
index 0000000..122f651
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo04/Grandson.java"
@@ -0,0 +1,8 @@
+package demo04;
+
+public class Grandson extends Father {
+ public void study()
+ {
+ System.out.println("孙子要向爷爷和爸爸学习");
+ }
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo04/Son.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo04/Son.java"
new file mode 100644
index 0000000..cc6338e
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo04/Son.java"
@@ -0,0 +1,11 @@
+package demo04;
+
+public class Son extends Father {
+ public Son()
+ {
+ System.out.println("子类构造方法被调用");
+ }
+ public void study(){
+ System.out.println(" 我要向爸爸学习");
+ }
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo04/Test.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo04/Test.java"
new file mode 100644
index 0000000..58a683c
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo04/Test.java"
@@ -0,0 +1,11 @@
+package demo04;
+
+public class Test {
+ public static void main(String[] args) {
+ Son son=new Son();
+ Grandson grandson=new Grandson();
+ Child child=new Child();
+ son.study();
+ grandson.study();
+ }
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo05/Demo05Test.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo05/Demo05Test.java"
new file mode 100644
index 0000000..1e0c413
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo05/Demo05Test.java"
@@ -0,0 +1,12 @@
+package demo05;
+
+public class Demo05Test {
+ public static void main(String[] args) {
+ MyInterfaceabsctract impl=new MyInterfaceabsctractImpl();
+ impl.methonAbs();
+ impl.methonDefault();
+ MyInterfaceabsctract.methonStatic();
+ }
+
+
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo05/MyInterfaceabsctract.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo05/MyInterfaceabsctract.java"
new file mode 100644
index 0000000..4d49ec0
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo05/MyInterfaceabsctract.java"
@@ -0,0 +1,12 @@
+package demo05;
+
+public interface MyInterfaceabsctract {
+ public abstract void methonAbs();
+ public default void methonDefault(){
+ System.out.println("这是接口中的一个默认方法");
+ }
+ public static void methonStatic()
+ {
+ System.out.println("这是接口的一个静态方法");
+ }
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo05/MyInterfaceabsctractImpl.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo05/MyInterfaceabsctractImpl.java"
new file mode 100644
index 0000000..19b61fa
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo05/MyInterfaceabsctractImpl.java"
@@ -0,0 +1,13 @@
+package demo05;
+
+public class MyInterfaceabsctractImpl implements MyInterfaceabsctract {
+
+ @Override
+ public void methonAbs() {
+ System.out.println("这是第一个方法");
+ }
+ @Override
+ public void methonDefault(){
+ System.out.println("覆盖重写的接口的默认方法");
+ }
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo06/Demo06Test.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo06/Demo06Test.java"
new file mode 100644
index 0000000..0a96ce8
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo06/Demo06Test.java"
@@ -0,0 +1,22 @@
+package demo06;
+
+public class Demo06Test {
+ public static void main(String[] args) {
+ /* Son son=new Son();
+ son.methon();
+ System.out.println(son.age);
+ */
+
+
+ Father object=new Son();
+ object.methon();
+ object.methodFather();
+ System.out.println(object.age);
+ Son son=(Son)object;
+ son.mmethonSon();
+ System.out.println("=========");
+ System.out.println(object instanceof Son);
+
+
+ }
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo06/Father.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo06/Father.java"
new file mode 100644
index 0000000..2575da9
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo06/Father.java"
@@ -0,0 +1,12 @@
+package demo06;
+
+public class Father {
+ int age=55;
+ public void methodFather()
+ {
+ System.out.println(age);
+ }
+ public void methon(){
+ System.out.println(age);
+ }
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo06/Son.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo06/Son.java"
new file mode 100644
index 0000000..4fda0ee
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo06/Son.java"
@@ -0,0 +1,17 @@
+package demo06;
+
+public class Son extends Father {
+ int age=22;
+ String name="JiaGuosheng";
+ @Override
+ public void methon()
+ {
+ //System.out.println(super.age);
+ System.out.println(age);
+
+ }
+ public void mmethonSon(){
+ System.out.println("这是子类特有的方法");
+ }
+
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo07/Demo07Test.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo07/Demo07Test.java"
new file mode 100644
index 0000000..ebc554c
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo07/Demo07Test.java"
@@ -0,0 +1,18 @@
+package demo07;
+
+public class Demo07Test {
+ public static void main(String[] args) {
+ Laptop laptop=new Laptop();
+ laptop.shutUp();
+ USB usbKeybroad=new KeyBroad();
+ USB usbMouse=new Mouse();
+
+ laptop.useDevice(usbKeybroad);
+ laptop.useDevice(usbMouse);
+ System.out.println("======");
+ laptop.useDevice(new Mouse());
+ laptop.useDevice(new KeyBroad());
+ laptop.shutDown();;
+
+ }
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo07/KeyBroad.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo07/KeyBroad.java"
new file mode 100644
index 0000000..3841c41
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo07/KeyBroad.java"
@@ -0,0 +1,16 @@
+package demo07;
+
+public class KeyBroad implements USB {
+ @Override
+ public void openDevice() {
+ System.out.println("打开键盘");
+ }
+
+ @Override
+ public void closeDevice() {
+ System.out.println("关闭键盘");
+ }
+ public void type(){
+ System.out.println("敲击键盘");
+ }
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo07/Laptop.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo07/Laptop.java"
new file mode 100644
index 0000000..0e5f534
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo07/Laptop.java"
@@ -0,0 +1,25 @@
+package demo07;
+
+public class Laptop {
+
+ public void useDevice(USB usb){
+ usb.openDevice();
+ if( usb instanceof Mouse)
+ {
+ Mouse mouse=(Mouse)usb;
+ mouse.click();
+ } else if (usb instanceof KeyBroad) {
+
+ KeyBroad keyBroad=(KeyBroad)usb;
+ keyBroad.type();
+ }
+ usb.closeDevice();
+ }
+ public void shutUp(){
+ System.out.println("笔记本开机了");
+ }
+ public void shutDown(){
+ System.out.println("笔记本关机了");
+ }
+
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo07/Mouse.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo07/Mouse.java"
new file mode 100644
index 0000000..f10e3e6
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo07/Mouse.java"
@@ -0,0 +1,16 @@
+package demo07;
+
+public class Mouse implements USB {
+ @Override
+ public void openDevice() {
+ System.out.println("打开鼠标");
+ }
+
+ @Override
+ public void closeDevice() {
+ System.out.println("关闭鼠标");
+ }
+ public void click(){
+ System.out.println("点击鼠标");
+ }
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo07/USB.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo07/USB.java"
new file mode 100644
index 0000000..3042482
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo07/USB.java"
@@ -0,0 +1,7 @@
+package demo07;
+
+public interface USB {
+ public abstract void openDevice();
+ public abstract void closeDevice();
+
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo08/Body.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo08/Body.java"
new file mode 100644
index 0000000..bccfe62
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo08/Body.java"
@@ -0,0 +1,27 @@
+package demo08;
+
+public class Body {
+ private String name;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void methonBody(){
+ System.out.println("这是外部类的方法");
+ new Internal().methonInternal();
+
+ }
+ //内部类
+ public class Internal{
+ public void methonInternal(){
+ System.out.println("这是内部类的方法");
+ System.out.println("我叫"+name);
+ }
+ }
+
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo08/MyInterface.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo08/MyInterface.java"
new file mode 100644
index 0000000..f5f7062
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo08/MyInterface.java"
@@ -0,0 +1,6 @@
+package demo08;
+
+public interface MyInterface {
+ public abstract void methon();
+
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo08/Outer.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo08/Outer.java"
new file mode 100644
index 0000000..0f02486
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo08/Outer.java"
@@ -0,0 +1,15 @@
+package demo08;
+
+public class Outer {
+ int num=10;
+ public class Inter{
+ int num=20;
+ public void methonInter()
+ {
+ int num=30;
+ System.out.println(num);
+ System.out.println(this.num);
+ System.out.println(Outer.this.num);
+ }
+ }
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo08/demo08Test.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo08/demo08Test.java"
new file mode 100644
index 0000000..64f795b
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo08/demo08Test.java"
@@ -0,0 +1,23 @@
+package demo08;
+
+public class demo08Test
+{
+ public static void main(String[] args) {
+ Body body=new Body();
+ body.setName("贾国胜");
+ body.methonBody();
+ System.out.println("===========");
+ Body.Internal internal=new Body().new Internal();
+ internal.methonInternal();
+ System.out.println("============");
+ Outer.Inter inter=new Outer().new Inter();
+ inter.methonInter();
+ System.out.println("===========");
+ MyInterface myInterface=new MyInterface() {
+ public void methon(){
+
+ System.out.println("匿名内部类的重写方法"); }
+ };
+ myInterface.methon();
+ }
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo09/Demo09Test.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo09/Demo09Test.java"
new file mode 100644
index 0000000..f733b16
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo09/Demo09Test.java"
@@ -0,0 +1,14 @@
+package demo09;
+
+public class Demo09Test {
+ public static void main(String[] args) {
+ Hero hero=new Hero();
+ hero.setName("鸣人");
+ hero.setAge(16);
+ Weapon weapon=new Weapon("螺旋丸");
+ hero.setWeapon(weapon);
+ hero.attack();
+
+ }
+}
+
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo09/DemoInterface.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo09/DemoInterface.java"
new file mode 100644
index 0000000..b5a95d1
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo09/DemoInterface.java"
@@ -0,0 +1,24 @@
+package demo09;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class DemoInterface {
+ public static void main(String[] args) {
+ //接口
+ Listlist=new ArrayList();//ArrayList 实现了List
+ addName(list);
+ for (int i = 0; i < list.size(); i++) { + System.out.println(list.get(i)); + } + } + + public static List addName(List list)
+ {
+ list.add("鸣人");
+ list.add("雏田");
+ list.add("博人");
+ list.add("向日葵");
+ return list;
+ }
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo09/Hero.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo09/Hero.java"
new file mode 100644
index 0000000..9517720
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo09/Hero.java"
@@ -0,0 +1,42 @@
+package demo09;
+
+public class Hero {
+ private String name;//英雄名字
+ private Weapon weapon;
+ private int age;
+ public void attack(){
+ System.out.println(age+"的"+name+"使用"+weapon.getCode());
+ }
+ public Hero() {
+ }
+
+ public Hero(String name, Weapon weapon, int age) {
+ this.name = name;
+ this.weapon = weapon;
+ this.age = age;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Weapon getWeapon() {
+ return weapon;
+ }
+
+ public void setWeapon(Weapon weapon) {
+ this.weapon = weapon;
+ }
+
+ public int getAge() {
+ return age;
+ }
+
+ public void setAge(int age) {
+ this.age = age;
+ }
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo09/Weapon.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo09/Weapon.java"
new file mode 100644
index 0000000..35d9db2
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo09/Weapon.java"
@@ -0,0 +1,20 @@
+package demo09;
+
+public class Weapon {
+ private String code;//武器代号
+ public Weapon()
+ {
+
+ }
+ public Weapon(String code) {
+ this.code = code;
+ }
+
+ public String getCode() {
+ return code;
+ }
+
+ public void setCode(String code) {
+ this.code = code;
+ }
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo10/Calendar/Demo10Calendar.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo10/Calendar/Demo10Calendar.java"
new file mode 100644
index 0000000..12f67a9
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo10/Calendar/Demo10Calendar.java"
@@ -0,0 +1,37 @@
+package demo10.Calendar;
+
+import java.util.Calendar;
+import java.util.Date;
+
+public class Demo10Calendar {
+ public static void main(String[] args) {
+ Calendar c=Calendar.getInstance();//多态写c法,getInstance()方法返回的是Calendar类的子类对象
+ System.out.println(c);
+ System.out.println(c.get(Calendar.YEAR));//get()方法返回给定日历字段的值
+ c.set(Calendar.YEAR,2022);//set()方法将给定的日历字段设置为给定的值
+ System.out.println(c.get(Calendar.YEAR));
+
+ Calendar cal = Calendar.getInstance();
+ // 设置年
+ int year = cal.get(Calendar.YEAR);
+ // 设置月
+ int month = cal.get(Calendar.MONTH) + 1;
+ // 设置日
+ int dayOfMonth = cal.get(Calendar.DAY_OF_MONTH);
+ System.out.println(year+"年"+month+"月"+dayOfMonth+"日");
+ //使用add()方法 加两天
+ cal.add(Calendar.DAY_OF_MONTH,2);
+ cal.add(Calendar.YEAR,2);
+ //获取修改后的年
+ year=cal.get(Calendar.YEAR);
+ //获取修改胡后的日
+ dayOfMonth=cal.get(Calendar.DAY_OF_MONTH);
+ //打印年月日
+ System.out.println(year+"年"+month+"月"+dayOfMonth+"日");
+ //Calendar类的gettime()方法返回的是Date类型的对象,不是毫秒值
+ Date date=cal.getTime();
+ System.out.println(date);
+
+
+ }
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo10/DateFormat/demo10DateFormat.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo10/DateFormat/demo10DateFormat.java"
new file mode 100644
index 0000000..1b133a3
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo10/DateFormat/demo10DateFormat.java"
@@ -0,0 +1,49 @@
+package demo10.DateFormat;
+
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Scanner;
+
+public class demo10DateFormat {
+ public static void main(String[] args) throws ParseException {
+ Date date=new Date();
+ System.out.println(new Date()); // Tue Jan 16 14:37:35 CST 2018
+ // 创建日期对象,把当前的毫秒值转成日期对象
+ System.out.println(new Date(0L)); // Thu Jan 01 08:00:00 CST 1970
+ DateFormat df=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ String str=df.format(date);
+ System.out.println(str);
+
+ DateFormat dateFormat=new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒");
+ Date date1=new Date();
+ try{
+ date1=dateFormat.parse("2020年01月27日 04时08分24秒");
+ }catch (ParseException e){
+ System.out.println(e);
+ }
+ System.out.println(date1);
+ System.out.println(counterDays());
+
+ }
+ public static long counterDays() throws ParseException {
+ //使用Scanner类的next()方法输入出生日期,使用birthdaydya变量接收出生日期字符串
+ String birthdaydays=new Scanner(System.in).next();
+ //使用DateFormat类中的parse()方法将字符串解析为Date格式
+ DateFormat df=new SimpleDateFormat("yyyy-MM-dd");
+ Date birthday=df.parse(birthdaydays);
+ //获取当前时间的日期
+ Date todayday=new Date();
+ //将出生日期转换为毫秒
+ long birthdaySecond=birthday.getTime();
+ //将当前日期转换为毫秒
+ long todaySecond=todayday.getTime();
+ //使用当前日期毫秒值-出生日期毫秒值
+ long second=todaySecond-birthdaySecond;
+ return (second/1000/60/60/24);
+ }
+
+
+}
+
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo10/Demo10Test.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo10/Demo10Test.java"
new file mode 100644
index 0000000..fe4255e
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo10/Demo10Test.java"
@@ -0,0 +1,30 @@
+package demo10;
+
+import java.util.Date;
+import java.util.Objects;
+
+public class Demo10Test {
+ public static void main(String[] args) {
+ Person person=new Person();
+ person.setName("贾国胜");
+ person.setAge(22);
+ System.out.println(person);
+ System.out.println(person.toString());
+ System.out.println("=============");
+ Person p1=new Person("迪丽热巴",25);
+ Person p2=new Person("迪丽热巴",25);
+ System.out.println("p1:"+p1);
+ System.out.println("p2:"+p2);
+ System.out.println(p1.equals(p2));
+ System.out.println(
+ Objects.equals(p1,p2)
+ );
+ System.out.println(System.currentTimeMillis());
+ System.out.println(new Date());
+ System.out.println(new Date().getTime());
+
+ String s1="abc";
+ String s2="abc";
+ System.out.println(s1.equals(s2));
+ }
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo10/Person.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo10/Person.java"
new file mode 100644
index 0000000..c109bed
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo10/Person.java"
@@ -0,0 +1,51 @@
+package demo10;
+
+public class Person {
+ private String name;
+ private int age;
+ //无参构造
+ public Person() {
+ }
+ // 有参构造
+ public Person(String name, int age) {
+ this.name = name;
+ this.age = age;
+ }
+ //重写toString 方法;
+ @Override
+ public String toString() {
+ return "Person{" +
+ "name='" + name + '\'' +
+ ", age=" + age +
+ '}';
+ }
+ @Override
+ public boolean equals(Object obj){
+ if(obj==this)
+ return true;
+ if(obj==null)
+ return false;
+ if(obj instanceof Person)
+ {
+ Person person=(Person)obj;
+ boolean b=this.age==person.age&&this.name==person.name;
+ return b;
+ }
+ return false;
+ }
+ 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;
+ }
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo10/StringBuildder/Demo10StringBuilder.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo10/StringBuildder/Demo10StringBuilder.java"
new file mode 100644
index 0000000..aaf940b
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo10/StringBuildder/Demo10StringBuilder.java"
@@ -0,0 +1,37 @@
+package demo10.StringBuildder;
+
+public class Demo10StringBuilder {
+ public static void main(String[] args) {
+ char[] array = {'a', 'b', 'c'};
+ String s = "hello";
+ s += "Hinata";
+ s = new String(array);
+ s = new String("naruto");
+ System.out.println(s);
+
+ StringBuilder bu1=new StringBuilder("Naruto");
+ StringBuilder bu2=bu1.append("-Hinata");//append()
+ System.out.println(bu2);
+ System.out.println(bu1==bu2);
+ Integer i=3;
+ i=i+3;
+ System.out.println(i);
+ //基本数据类型转换为字符串类型的三种方式:
+ /*
+ 1.基本数据类型的值+" ";
+ 2.使用包装类的静态方法;
+ public static String toSting(int i):返回一个指定参数的的String对象
+ 3.使用String类的静态方法;
+ static String valueOf(int i):返回一个int参数的字符串表现形式
+
+ */
+ String str1=1+"";
+
+ String str2=Integer.toString(6);
+ String str3=String.valueOf(7);
+ System.out.println(str1+str2+str3);
+
+
+
+ }
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo10/Sysyem/Demo0System.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo10/Sysyem/Demo0System.java"
new file mode 100644
index 0000000..872be2e
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo10/Sysyem/Demo0System.java"
@@ -0,0 +1,17 @@
+package demo10.Sysyem;
+
+public class Demo0System {
+ public static void main(String[] args) {
+ //currentTimeMillis方法就是 获取当前系统时间与1970年01月01日00:00点之间的毫秒差值
+ System.out.println(System.currentTimeMillis());
+ //public static void arraycopy
+ // (Object src, int srcPos, Object dest, int destPos, int length)`:
+ // 将数组中指定的数据拷贝到另一个数组中。
+ int[] src = new int[]{1,2,3,4,5};
+ int[] dest = new int[]{6,7,8,9,10};
+ System.arraycopy( src, 0, dest, 0, 3);
+ for (int i : dest) {
+ System.out.print(i+" ");
+ }
+ }
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo11/Collection/Demo11Collection.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo11/Collection/Demo11Collection.java"
new file mode 100644
index 0000000..eb9d7dc
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo11/Collection/Demo11Collection.java"
@@ -0,0 +1,26 @@
+package demo11.Collection;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+public class Demo11Collection {
+ public static void main(String[] args) {
+ Collection arraylist=new ArrayList();
+ arraylist.add("Naruto");
+ arraylist.add("hinata");
+ System.out.println(arraylist);
+ System.out.println(arraylist.size());
+ for (String s : arraylist) {
+ System.out.println(s);
+ }
+ Object [] objects=arraylist.toArray();
+ for(int i=0;i student1=new Student();//也可以在创建对象时候,直接使用泛型格式,其成员变量
+ //都将使用这个数据类型
+ student1.setName(123);
+ System.out.println(student.getName());
+ System.out.println(student1.getName());
+ //
+ student.study("我要学习了");
+ student1.study(3.444);
+ }
+
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo11/Generic/Student.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo11/Generic/Student.java"
new file mode 100644
index 0000000..a9ca53a
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo11/Generic/Student.java"
@@ -0,0 +1,34 @@
+package demo11.Generic;
+/*
+ 泛型类的定义格式
+ public class 类名称{
+ //...
+ }
+ */
+public class Student {
+ private E name;
+ private int agr;
+
+ public Student() {
+ }
+
+ public E getName() {
+ return name;
+ }
+
+ public void setName(E name) {
+ this.name = name;
+ }
+
+ public int getAgr() {
+ return agr;
+ }
+ //定义泛型方法的格式,调用方法时确定泛型的类型
+ public void setAgr(int agr) {
+ this.agr = agr;
+ }
+ public void study(E e)
+ {
+ System.out.println(e);
+ }
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo11/Iterator/Demo11Iterator.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo11/Iterator/Demo11Iterator.java"
new file mode 100644
index 0000000..7149109
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo11/Iterator/Demo11Iterator.java"
@@ -0,0 +1,25 @@
+package demo11.Iterator;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+
+public class Demo11Iterator {
+ public static void main(String[] args) {
+ Collection col=new ArrayList();
+ col.add("科比");
+ col.add("乔丹");
+ col.add("詹姆斯");
+ col.add("麦迪");
+ col.add("艾佛森");
+ //多态 //集合的iterator()方法返回迭代器对象
+ Iterator iterator=col.iterator();
+ //hasNext()方法判断集合中是否还有下一个元素
+ //next()方法去除集合下一个元素
+ while(iterator.hasNext())
+ {
+ System.out.println(iterator.next());
+ }
+
+ }
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo12/HashSet/HashsetTest.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo12/HashSet/HashsetTest.java"
new file mode 100644
index 0000000..b535b13
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo12/HashSet/HashsetTest.java"
@@ -0,0 +1,52 @@
+package demo12.HashSet;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+/*
+ 1.java.util.Set接口继承了Collection接口
+ Set接口的特点:
+ 1.不允许有重复的元素
+ 2.Set集合中元素是无序的,没有索引不能使用简单的for循环遍历
+ jva.util.HashSet实现了Set接口
+ HashSet接口特点:
+ 1.不允许重复的元素
+ 2.没有索引,没有带索引的方法,不能使用普通的for循环
+ 3.是一个无序的集合。
+ 4.底层是哈希表结构,存储和查找快
+ */
+public class HashsetTest {
+
+ public static void main(String[] args) {
+ Set set=new HashSet();
+ set.add("鸣人");
+ set.add("雏田");
+ set.add("佐助");
+ System.out.println(set.size());
+ System.out.println(set.isEmpty());
+ System.out.println(set.contains("佐助"));
+ System.out.println(set.remove("佐助"));
+ //使用迭代器遍历集合
+ Iterator it=set.iterator();
+ while(it.hasNext())
+ {
+ System.out.println(it.next());
+ System.out.println(set.hashCode());
+ }
+ Person p1=new Person();
+ Person p2=new Person();
+ System.out.println(p1.hashCode());
+ System.out.println(p2.hashCode());
+ System.out.println(p1.equals(p2));
+ System.out.println("================");
+ String s1=new String("贾");
+ String s2=new String("贾");
+ System.out.println(s1.hashCode());
+ System.out.println(s2.hashCode());
+ System.out.println(s1==s2);
+
+
+
+ }
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo12/HashSet/Person.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo12/HashSet/Person.java"
new file mode 100644
index 0000000..8b7cb9c
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo12/HashSet/Person.java"
@@ -0,0 +1,8 @@
+package demo12.HashSet;
+
+public class Person extends Object {
+ @Override
+ public int hashCode(){
+ return 1;
+ }
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo12/Sort/Person.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo12/Sort/Person.java"
new file mode 100644
index 0000000..442f1e0
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo12/Sort/Person.java"
@@ -0,0 +1,38 @@
+package demo12.Sort;
+
+public class Person {
+ private String name;
+ private int age;
+
+ public Person() {
+ }
+
+ @Override
+ public String toString() {
+ return "Person{" +
+ "name='" + name + '\'' +
+ ", age=" + age +
+ '}';
+ }
+
+ public Person(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;
+ }
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo12/Sort/SortTest.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo12/Sort/SortTest.java"
new file mode 100644
index 0000000..e717400
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo12/Sort/SortTest.java"
@@ -0,0 +1,32 @@
+package demo12.Sort;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+/*
+ Collections 的Sort()方法
+ */
+public class SortTest {
+ public static void main(String[] args) {
+ List arraylist=new ArrayList();
+ arraylist.add(new Person("鸣人",16));
+ arraylist.add(new Person("佐助",17));
+ arraylist.add(new Person("雏田",15));
+ System.out.println(arraylist);
+ //匿名内部类的方式,重写comparator的compare()方法,自定义排序的方式。
+ Collections.sort(arraylist, new Comparator() {
+ @Override
+ public int compare(Person o1, Person o2) {
+ //o1-o2升序
+ // return o1.getAge()-o2.getAge();
+ //o2-o1降序
+ return o2.getAge()-o1.getAge();
+ }
+ }
+ );
+ System.out.println(arraylist);
+
+ }
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo13/HashMap/HashMapTest.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo13/HashMap/HashMapTest.java"
new file mode 100644
index 0000000..9bf4152
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo13/HashMap/HashMapTest.java"
@@ -0,0 +1,63 @@
+package demo13.HashMap;
+
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Set;
+
+
+public class HashMapTest {
+ public static void main(String[] args) {
+ show();
+ methon();
+ showListedHashMap();
+ }
+ /*
+ HashMap存储自定义键值对
+ key:String类型
+ String类重写hashcode方法和equals()方法,可以保证key唯一
+ value: Person类型
+ */
+ public static void show()
+ {
+ //创建Hashmap集合
+ Map map=new HashMap();
+ //往集合中添加元素
+ map.put("北京",new Person("张三",18));
+ map.put("上海",new Person("李四",19));
+ map.put("广州",new Person("王五",20));
+ map.put("北京",new Person("赵六",18));
+ Set set=map.keySet();
+ for (String s:set) {
+ Person value=map.get(s);
+ System.out.println(value.getName()+":"+value.getAge());
+ }
+
+ }
+ /*
+ HashMap存储自定义键值对
+ key:Person类型,需要重写hashcode()和equals()方法。
+ value: String类型
+ */
+ public static void methon(){
+ Map map=new HashMap();
+ //往集合中添加元素
+ map.put(new Person("张三",18),"北京");
+ map.put(new Person("李四",19),"上海");
+ map.put(new Person("王五",20),"广州");
+ map.put(new Person("赵六",18),"北京");
+ Set set=map.keySet();
+ for (Person personn:set) {
+ String area=map.get(personn);
+ System.out.println(personn.getName()+":"+personn.getAge()+":"+area);
+
+ }
+ }
+ public static void showListedHashMap(){
+ LinkedHashMap map=new LinkedHashMap();
+ map.put("刘亦菲",33);
+ map.put("刘诗诗",31);
+ map.put("罗思雨",22);
+ System.out.println(map);
+ }
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo13/HashMap/Person.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo13/HashMap/Person.java"
new file mode 100644
index 0000000..66d6240
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo13/HashMap/Person.java"
@@ -0,0 +1,49 @@
+package demo13.HashMap;
+
+import java.util.Objects;
+
+public class Person {
+ private String name;
+ private int age;
+
+ public Person() {
+ }
+
+ public Person(String name, int age) {
+ this.name = name;
+ this.age = age;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(name,age);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if(this==obj)
+ return true;
+ if(obj==null||getClass()!=obj.getClass()){
+ return false;
+ }
+ Person person=(Person)obj;
+ return age==person.age&&Objects.equals(name,person.name);
+ }
+
+
+ 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;
+ }
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo13/Map/MapTest.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo13/Map/MapTest.java"
new file mode 100644
index 0000000..9406f43
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo13/Map/MapTest.java"
@@ -0,0 +1,100 @@
+package demo13.Map;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+/*
+ Map集合的常用方法:
+
+ */
+public class MapTest {
+ public static void main(String[] args) {
+ showPut();
+ showRemove();
+ showGet();
+ show();
+ }
+ /*
+ public V put(K key, V value):把指定的键和指定的值添加到map集合中
+ 返回值v:
+ 1. 存储键值对的时候如果key不重复,返回null
+ 2.存储对象的时候key重复,会使用新的value值替换map集合中的value
+
+ */
+ public static void showPut(){
+ Map map=new HashMap();
+ map.put("刘亦菲",33);
+ map.put("刘诗诗",31);
+ map.put("罗思雨",22);
+ System.out.println(map);
+
+ }
+ /*
+ public V remove(Object key):把指定的键所对应的键值对从map集合中删除,返回被删除元素的值。
+ 返回值v:
+ 1.key存在,返回被删除键值对的值。
+ 2.key不存在,返回null
+ */
+ public static void showRemove(){
+ Map map=new HashMap();
+ map.put("刘亦菲",33);
+ map.put("刘诗诗",31);
+ map.put("罗思雨",22);
+ // map.remove("刘亦菲");
+ //System.out.println(map.remove("孙玥"));
+ System.out.println(map);
+ }
+ /*
+ public V get(Object key)`:根据指定的键,在Map集合中获取对应的值。
+ 返回值v:
+ 1.key存在,返回key对应的值。
+ 2.key不存在,返回null
+ */
+ public static void showGet(){
+ Map map=new HashMap();
+ map.put("刘亦菲",33);
+ map.put("刘诗诗",31);
+ map.put("罗思雨",22);
+ System.out.println(map.get("罗思雨"));
+ //`boolean containsKey(Object key) `:判断集合中是否包含指定的键。
+ System.out.println("map中是否含有罗思雨:"+map.containsKey("罗思雨"));
+ //public Set keySet(): 获取Map集合中所有的键,存储到Set集合中。
+ Set set=map.keySet();
+ System.out.println(set);
+
+
+ }
+
+ public static void show(){
+
+ Map map=new HashMap();
+ map.put("刘亦菲",33);
+ map.put("刘诗诗",31);
+ map.put("罗思雨",22);
+ //map集合的第一种便利方式
+ for (String str:map.keySet()){
+ System.out.println(str+":"+map.get(str));
+ }
+ //map集合的第二种便利方式
+ //1.使用map集合中的entrySet()方法,把map中的多个Entry对象存储到set集合中
+ Set> set=map.entrySet();
+ //2.
+ Iterator> iterator = set.iterator();
+ while(iterator.hasNext()){
+ Map.Entry entry=iterator.next();
+ String name=entry.getKey();
+ int age=entry.getValue();
+ System.out.println(name+":"+age);
+
+ }
+ for (Map.Entry entry:map.entrySet()
+ ) {
+ System.out.println(entry.getKey()+":"+entry.getValue());
+
+ }
+
+ }
+
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo13/Practice/PracticeTest.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo13/Practice/PracticeTest.java"
new file mode 100644
index 0000000..b69d012
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo13/Practice/PracticeTest.java"
@@ -0,0 +1,40 @@
+package demo13.Practice;
+
+import java.util.HashMap;
+import java.util.Scanner;
+/*
+ IDEA debug使用
+ F8单步执行
+ F7进入方法
+ F9跳到下一个断点
+ ctrl+f2 推出debug模式
+ */
+public class PracticeTest {
+ public static void main(String[] args) {
+ //友情提示
+ System.out.println("请录入一个字符串:");
+ String line = new Scanner(System.in).nextLine();
+ // 定义 每个字符出现次数的方法
+ findChar(line);
+ }
+ private static void findChar(String line) {
+ //1:创建一个集合 存储 字符 以及其出现的次数
+ HashMap map = new HashMap();
+ //2:遍历字符串
+ for (int i = 0; i < line.length(); i++) { + char c = line.charAt(i); + //判断 该字符 是否在键集中 + if (!map.containsKey(c)) {//说明这个字符没有出现过 + //那就是第一次 + map.put(c, 1); + } else { + //先获取之前的次数 + Integer count = map.get(c); + //count++; + //再次存入 更新 + map.put(c, ++count); + } + } + System.out.println(map); + } +} diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo14/Exception/DemoException.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo14/Exception/DemoException.java" new file mode 100644 index 0000000..e634f7e --- /dev/null +++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo14/Exception/DemoException.java" @@ -0,0 +1,35 @@ +package demo14.Exception; + +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; + +/* + java.lang.Throwable是Java中所有错误和异常的超类 + Exception:编译异常 + RunTimeException:运行异常 + Error:错误 + */ +public class DemoException { + public static void main(String[] args) { + DateFormat df=new SimpleDateFormat("yyyy-MM-dd"); + Date date=new Date(); + //使用Try Carch处理异常,程序不会终止,会继续执行发生异常后面的代码 + try { + date=df.parse("2020-10-19"); + }catch (ParseException e) + { + e.printStackTrace(); + } + System.out.println(date); + System.out.println("继续执行"); + + /*RunTimeException异常 + 发生运行异常,会终止程序的运行 + */ + int []arr={1,2,3}; + System.out.println(arr[3]); + System.out.println("继续执行"); + } +} diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo14/Exception/DemoThrow.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo14/Exception/DemoThrow.java" new file mode 100644 index 0000000..e1f9f22 --- /dev/null +++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo14/Exception/DemoThrow.java" @@ -0,0 +1,41 @@ +package demo14.Exception; +/* + Throw关键字 + 可以使用Throw关键字方法中抛出指定的异常 + 使用格式: + throw new xxxException("产生异常的原因"); + 注意:1.throw关键字必须写在方法的内部 + 2.throw关键字后面new的对象 必须是Exception或者Exception类的子类对象 + 3.throw关键字抛出指定的异常对象,必须处理这个异常对象 + throw关键字后面创建的是RuntimeException或者RuntimeException子类对象,无需程序员自己处理。 + throw关键字后面创建是编译异常,必须处理异常:1.throws,2.try...catch + + */ +public class DemoThrow { + public static void main(String[] args) { + int [] arr={1,2,3}; + int ele=getElement(arr,2); + System.out.println(ele); + } + /* + NullPointerException是一个运行期异常,程序员无需处理 + */ + public static int getElement(int []arr,int index) + { + /* 检验参数arr: + 注意:NullPointerException是一个运行期异常,程序员无需处理 + */ + if(arr==null){ + throw new NullPointerException("传递的数组是null"); + } + /*检验参数index:index不能越界; + 注意:ArrayIndexOutOfBoundsException是一个运行期异常,程序员无需处理 + */ + if(index<0||index>arr.length-1)
+ {
+ throw new ArrayIndexOutOfBoundsException("数组下标越界了");
+ }
+ int ele=arr[index];
+ return ele;
+ }
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo14/Exception/DemoThrows.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo14/Exception/DemoThrows.java"
new file mode 100644
index 0000000..997fa7c
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo14/Exception/DemoThrows.java"
@@ -0,0 +1,11 @@
+package demo14.Exception;
+
+/*
+ Throws关键字:异常处理的第一钟方式,交给方法的调用者处理
+ 作用:
+ 当方法的内部抛出异常的时候,那么我们就必须处理这个异常。
+ 使用Throws关键字处理异常对,会把异常对象声明抛出给方法的调用者:最终交给jvm处理:中断处理
+ 使用格式:
+ */
+public class DemoThrows {
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo15/InnerClassThread/InnerClassThread.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo15/InnerClassThread/InnerClassThread.java"
new file mode 100644
index 0000000..812a47c
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo15/InnerClassThread/InnerClassThread.java"
@@ -0,0 +1,33 @@
+package demo15.InnerClassThread;
+
+/*
+ 匿名内部类实现线程的创建
+ 格式:
+ 1.new 父类/接口(){
+ 重写父类或者接口的run()方法
+ };
+ */
+public class InnerClassThread {
+ public static void main(String[] args) {
+ //线程的父类是Thread
+ new Thread(){
+ @Override
+ public void run() {
+ for (int i = 0; i <20 ; i++) { + System.out.println(Thread.currentThread().getName()+"-->"+i);
+ }
+ }
+ }.start();
+ //线程接口Runnable
+ Runnable runnable=new Runnable(){//多态的形式
+ @Override
+ public void run() {
+ for (int i = 0; i <20 ; i++) { + System.out.println(Thread.currentThread().getName()+"-->"+i);
+ }
+ }
+ };
+ new Thread(runnable).start();
+
+ }
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo15/Runnable/DemoRunnable.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo15/Runnable/DemoRunnable.java"
new file mode 100644
index 0000000..449c8ea
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo15/Runnable/DemoRunnable.java"
@@ -0,0 +1,20 @@
+package demo15.Runnable;
+/*
+采用 java.lang.Runnable 也是非常常见的一种,我们只需要重写run方法即可。
+步骤如下:
+1. 定义Runnable接口的实现类,并重写该接口的run()方法,该run()方法的方法体同样是该线程的线程执行体。
+2. 创建Runnable实现类的实例,并以此实例作为Thread的target来创建Thread对象,该Thread对象才是真正
+的线程对象。
+3. 调用线程对象的start()方法来启动线程。
+代码如下
+ */
+public class DemoRunnable {
+ public static void main(String[] args) {
+ RunnableImpl runnable=new RunnableImpl();
+ Thread thread=new Thread(runnable);
+ thread.start();
+ for (int i = 0; i <20 ; i++) { + System.out.println("main-->"+i);
+ }
+ }
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo15/Runnable/RunnableImpl.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo15/Runnable/RunnableImpl.java"
new file mode 100644
index 0000000..8b66f9c
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo15/Runnable/RunnableImpl.java"
@@ -0,0 +1,10 @@
+package demo15.Runnable;
+
+public class RunnableImpl implements Runnable {
+ @Override
+ public void run() {
+ for (int i = 0; i <20 ; i++) { + System.out.println("new Thread-->"+i);
+ }
+ }
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo15/Thread/Demo01Thread.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo15/Thread/Demo01Thread.java"
new file mode 100644
index 0000000..7ab1c7c
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo15/Thread/Demo01Thread.java"
@@ -0,0 +1,49 @@
+package demo15.Thread;
+
+/*
+ 创建多线程的第一种方式:
+ java.lang.Thread类:是描述线程的类,实现多线程必须继承Thread类
+ 实现步骤:
+ 1.创建Thread的子类
+ 2.在Thread类的子类中重写Thred类中的run方法,设置线程任务
+ 3.创建Thread类的子类对象
+ 4.调用Thread类中的start()方法,开启新的线程,执行run方法
+ void start():使得线程开始执行;Java虚拟机调用run()方法
+ 结果是两个线程并发执行,当前线程(main)和创建的新的线程
+ */
+public class Demo01Thread {
+ public static void main(String[] args) {
+ // MyThread myThread=new MyThread();
+
+ // myThread.start();
+ /* for (int i = 0; i <10 ; i++) { + System.out.println("主线程:"+i); + }*/ + /* + Thread类常用的方法 + 1.public String getName() :获取当前线程名称 + 2.public static Thread currentThread() :返回对当前正在执行的线程对象的引用。 + 使用currentThread()方法返回当前执行的线程,在调用getName()方法获取当前运行线程的名称 + */ + /* System.out.println(myThread.getName()); + //setName()方法设置线程名称 + myThread.setName("new thread"); + System.out.println(myThread.getName()); + System.out.println(Thread.currentThread().getName());*/ + + /* + sleep()方法使得线程暂停执行 + + */ + for (int i = 1; i <=60 ; i++) { + System.out.println(i); + try { + Thread.sleep(1000); + }catch(InterruptedException e) + { + e.printStackTrace(); + } + } + + } +} diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo15/Thread/MyThread.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo15/Thread/MyThread.java" new file mode 100644 index 0000000..37cfca1 --- /dev/null +++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo15/Thread/MyThread.java" @@ -0,0 +1,10 @@ +package demo15.Thread; +//创建Thread的子类 +public class MyThread extends Thread{ + @Override + public void run() { + for (int i = 0; i <10 ; i++) { + System.out.println("新线程:"+i); + } + } +} diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo15/ThreadSecurity/Lock/RunnableImpl.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo15/ThreadSecurity/Lock/RunnableImpl.java" new file mode 100644 index 0000000..3ef955a --- /dev/null +++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo15/ThreadSecurity/Lock/RunnableImpl.java" @@ -0,0 +1,63 @@ +package demo15.ThreadSecurity.Lock; + +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReentrantLock; + +/* + 一、解决线程安全问题得一种方案:使用同步代码块; + 格式: + synchronized(锁对象){ + 可能会出现线程安全得代码(访问共享数据得代码) + } + 注意: + 1.通过代码块中得锁对象,可以使用任意得对象 + 2.但是必须保证多个线程使用的锁对象是同一个 + 3.锁对象可以把同步代码块锁住,只让一个线程在同步代码中执行 + 原理:同步的线程没有执行完毕,不会释放锁,同步外的线程没有锁进不去同步。 + 保证同一时刻只有一个线程执行同步代码块 + + 二、解决线程安全问题得二种方案:使用同步方法; + 使用步骤: + 1.把访问共享数据那段代码抽取出来,放在一个方法中 + 2.在方法上添加synchronized修饰符 + 格式: + 修饰符 synchronized 返回值类型 方法名(){ + 把访问共享数据那段代码抽取出来 + } + 三、解决线程安全问题得二种方案:Lock锁; + java.util.conceurrent.locks.Lock接口 + Lock接口中的方法: + void lock()获取锁 + void unLock()释放锁 + + 步骤:1.在成员位置创建一个ReentrantLock对象 + 2.在可能会出现安全问题的代码前调用Lock()接口中的方法Lock获取锁 + 3.在可能会出现安全问题的代码后调用unLock()接口中的方法unLock释放锁 + + + */ +public class RunnableImpl implements Runnable { + private int takects=100; + Lock lock=new ReentrantLock(); + @Override + public void run() { + while (true){ + lock.lock(); + if (takects> 0) {
+ try {
+ Thread.sleep(10);
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ System.out.println(Thread.currentThread().getName() + "线程正在售票-->" + takects);
+ takects--;
+ }
+ lock.unlock();
+ }
+ }
+
+
+
+
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo15/ThreadSecurity/Lock/ThreadSecurity.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo15/ThreadSecurity/Lock/ThreadSecurity.java"
new file mode 100644
index 0000000..9c9ac97
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo15/ThreadSecurity/Lock/ThreadSecurity.java"
@@ -0,0 +1,16 @@
+package demo15.ThreadSecurity.Lock;
+
+/*
+线程安全问题
+ */
+public class ThreadSecurity {
+ public static void main(String[] args) {
+ RunnableImpl runnable=new RunnableImpl();
+ Thread r1=new Thread(runnable);
+ Thread r2=new Thread(runnable);
+ Thread r3=new Thread(runnable);
+ r1.start();
+ r2.start();
+ r3.start();
+ }
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo15/ThreadSecurity/RunnableImpl.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo15/ThreadSecurity/RunnableImpl.java"
new file mode 100644
index 0000000..dce66ad
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo15/ThreadSecurity/RunnableImpl.java"
@@ -0,0 +1,84 @@
+package demo15.ThreadSecurity;
+
+/*
+ 解决线程安全问题得一种方案:使用同步代码块;
+ 格式:
+ synchronized(锁对象){
+ 可能会出现线程安全得代码(访问共享数据得代码)
+ }
+ 注意:
+ 1.通过代码块中得锁对象,可以使用任意得对象
+ 2.但是必须保证多个线程使用的锁对象是同一个
+ 3.锁对象可以把同步代码块锁住,只让一个线程在同步代码中执行
+ 原理:同步的线程没有执行完毕,不会释放锁,同步外的线程没有锁进不去同步。
+ 保证同一时刻只有一个线程执行同步代码块
+ 解决线程安全问题得二种方案:使用同步方法;
+ 使用步骤:
+ 1.把访问共享数据那段代码抽取出来,放在一个方法中
+ 2.在方法上添加synchronized修饰符
+ 格式:
+ 修饰符 synchronized 返回值类型 方法名(){
+ 把访问共享数据那段代码抽取出来
+ }
+
+
+ */
+public class RunnableImpl implements Runnable {
+ private int takects=100;
+ /*用同步代码块
+
+ //创建一个锁对象
+ Object obj=new Object();
+ @Override
+ public void run() {
+ while(true)
+ {
+ synchronized (obj){
+ if(takects>0)
+ {
+ try{
+ Thread.sleep(10);
+
+ }catch(Exception e){
+ e.printStackTrace();
+ }
+ System.out.println(Thread.currentThread().getName()+"线程正在售票-->"+takects);
+ takects--;
+ }
+ }
+ }
+
+ }
+
+
+ /*
+ 使用同步方法
+ 锁对象是Runnaable的实现类对象,也就是RunnableImpl类的对象
+ 静态方法锁对象:
+ 不能是this
+ 静态方法的锁对象是本类的class属性(反射)
+
+ */
+
+ @Override
+ public void run() {
+ while(true)
+ {
+ playTickets();
+ }
+ }
+ public synchronized void playTickets()
+ {
+ if(takects>0)
+ {
+ try{
+ Thread.sleep(10);
+
+ }catch(Exception e){
+ e.printStackTrace();
+ }
+ System.out.println(Thread.currentThread().getName()+"线程正在售票-->"+takects);
+ takects--;
+ }
+ }
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo15/ThreadSecurity/ThreadSecurity.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo15/ThreadSecurity/ThreadSecurity.java"
new file mode 100644
index 0000000..cf4690d
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo15/ThreadSecurity/ThreadSecurity.java"
@@ -0,0 +1,15 @@
+package demo15.ThreadSecurity;
+/*
+线程安全问题
+ */
+public class ThreadSecurity {
+ public static void main(String[] args) {
+ RunnableImpl runnable=new RunnableImpl();
+ Thread r1=new Thread(runnable);
+ Thread r2=new Thread(runnable);
+ Thread r3=new Thread(runnable);
+ r1.start();
+ r2.start();
+ r3.start();
+ }
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo16ThreadandLambda/Lambda/Person.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo16ThreadandLambda/Lambda/Person.java"
new file mode 100644
index 0000000..4f813fc
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo16ThreadandLambda/Lambda/Person.java"
@@ -0,0 +1,38 @@
+package demo16ThreadandLambda.Lambda;
+
+public class Person {
+ private String name;
+ private int age;
+
+ public Person() {
+ }
+
+ public Person(String name, int age) {
+ this.name = name;
+ this.age = age;
+ }
+
+ @Override
+ public String toString() {
+ return "Person{" +
+ "name='" + name + '\'' +
+ ", 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;
+ }
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo16ThreadandLambda/Lambda/Test.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo16ThreadandLambda/Lambda/Test.java"
new file mode 100644
index 0000000..d3e8c26
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo16ThreadandLambda/Lambda/Test.java"
@@ -0,0 +1,30 @@
+package demo16ThreadandLambda.Lambda;
+import java.util.Arrays;
+import java.util.Comparator;
+
+public class Test {
+ public static void main(String[] args) {
+ Person [] array={
+ new Person("刘诗诗",33),
+ new Person("迪丽热巴",29),
+ new Person("柳岩",36)
+ };
+ Arrays.sort(array, new Comparator() {
+ @Override
+ public int compare(Person o1, Person o2) {
+ return o1.getAge()-o2.getAge();
+ }
+ });
+ for (Person person:array
+ ) {
+ System.out.println(person);
+ }
+ Arrays.sort(array, (Person o1,Person o2)->{
+ return o2.getAge()-o1.getAge();
+ });
+ for (Person person:array
+ ) {
+ System.out.println(person);
+ }
+ }
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo16ThreadandLambda/ThreadPool/RunnableImpl.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo16ThreadandLambda/ThreadPool/RunnableImpl.java"
new file mode 100644
index 0000000..5b204f2
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo16ThreadandLambda/ThreadPool/RunnableImpl.java"
@@ -0,0 +1,11 @@
+package demo16ThreadandLambda.ThreadPool;
+
+public class RunnableImpl implements Runnable {
+ @Override
+ public void run() {
+
+ System.out.println(Thread.currentThread().getName()+"创建了一个新的线程");
+
+
+ }
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo16ThreadandLambda/ThreadPool/ThreadPool.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo16ThreadandLambda/ThreadPool/ThreadPool.java"
new file mode 100644
index 0000000..bad81b1
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo16ThreadandLambda/ThreadPool/ThreadPool.java"
@@ -0,0 +1,29 @@
+package demo16ThreadandLambda.ThreadPool;
+
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+/*
+ 线程池:JDK1.5后提供的java.util.Excutors:线程池的工厂类,用来生成线程池
+ Excutors类中的静态方法static ExecutorService newFixedRThreadPool(int nThreads)
+ 参数:int nThreads 创建线程中包含线程的数量
+
+ 返回值:ExecutorService,返回时ExecutorService接口类的实现类对象,可以使用ExecutorService接口来接收
+ 线程池使用步骤:
+ 1.使用线程池工厂类Executors里面的静态方法newFixedRThreadPool(int nThreads)生产一个指定线程数量的线程池
+ 2.创建一个实现Runnable接口的实现类,重写run方法,设置线程任务
+ 3.调用ExecutorService()中的submit()方法传递线程任务,执行任务
+ 4.ExecutorService()中的shutdown()方法销毁线程
+ */
+public class ThreadPool {
+ public static void main(String[] args) {
+ // 1.使用线程池工厂类Executors里面的静态方法newFixedRThreadPool(int nThreads)生产一个指定线程数量的线程池
+ ExecutorService es=Executors.newFixedThreadPool(2);
+ // 3.调用ExecutorService()中的submit()方法传递线程任务,执行任务
+ es.submit(new RunnableImpl());
+ es.submit(new RunnableImpl());
+ es.submit(new RunnableImpl());
+
+ }
+
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo16ThreadandLambda/WaitingAndNotify/Baozi.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo16ThreadandLambda/WaitingAndNotify/Baozi.java"
new file mode 100644
index 0000000..8a7c162
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo16ThreadandLambda/WaitingAndNotify/Baozi.java"
@@ -0,0 +1,8 @@
+package demo16ThreadandLambda.WaitingAndNotify;
+
+public class Baozi {
+ String pi;//包子皮
+ String xian;//包子馅
+ boolean flag=false;//包子状态
+
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo16ThreadandLambda/WaitingAndNotify/BaoziStore.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo16ThreadandLambda/WaitingAndNotify/BaoziStore.java"
new file mode 100644
index 0000000..121c3be
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo16ThreadandLambda/WaitingAndNotify/BaoziStore.java"
@@ -0,0 +1,47 @@
+package demo16ThreadandLambda.WaitingAndNotify;
+
+public class BaoziStore extends Thread {
+ Baozi baozi;
+
+ public BaoziStore(Baozi baozi) {
+ this.baozi = baozi;
+ }
+
+ @Override
+ public void run() {
+ int count=0;
+ int n=10;
+ while(n>0)
+ synchronized (baozi){
+ if(baozi.flag==true){
+ try {
+ baozi.wait();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ if(count%2==0){
+ baozi.pi="薄皮";
+ baozi.xian="牛肉";
+ }else{
+ baozi.pi="厚皮";
+ baozi.xian="猪肉芹菜";
+ }
+ count++;
+ System.out.println("包子铺正在生产:"+baozi.pi+baozi.xian+"包子");
+ try{
+ Thread.sleep(3000);
+ }catch (Exception e){
+ e.printStackTrace();
+ }
+ baozi.flag=true;
+ System.out.println("包子铺已经生产好了:"+baozi.pi+baozi.xian+"包子,顾客可以吃了");
+ n--;
+ baozi.notify();
+
+
+ }
+ }
+
+
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo16ThreadandLambda/WaitingAndNotify/Consumer.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo16ThreadandLambda/WaitingAndNotify/Consumer.java"
new file mode 100644
index 0000000..2d53d73
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo16ThreadandLambda/WaitingAndNotify/Consumer.java"
@@ -0,0 +1,33 @@
+package demo16ThreadandLambda.WaitingAndNotify;
+
+public class Consumer extends Thread{
+ Baozi baozi;
+
+ public Consumer(Baozi baozi) {
+ this.baozi = baozi;
+ }
+
+ @Override
+ public void run() {
+ int n=10;
+ while (n>0){
+ synchronized (baozi){
+
+ if(baozi.flag==false){
+ try {
+ baozi.wait();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+
+ }
+ System.out.println("顾客正在吃:"+baozi.pi+baozi.xian+"包子");
+ System.out.println("顾客已经吧:"+baozi.pi+baozi.xian+"包子吃完了");
+ baozi.flag=false;
+ baozi.notify();
+ }
+ n--;
+ }
+
+ }
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo16ThreadandLambda/WaitingAndNotify/Test.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo16ThreadandLambda/WaitingAndNotify/Test.java"
new file mode 100644
index 0000000..1882b72
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo16ThreadandLambda/WaitingAndNotify/Test.java"
@@ -0,0 +1,13 @@
+package demo16ThreadandLambda.WaitingAndNotify;
+
+public class Test {
+ public static void main(String[] args) {
+
+ Baozi baozi=new Baozi();
+ BaoziStore bs=new BaoziStore(baozi);
+ Consumer consumer=new Consumer(baozi);
+ bs.start();
+ consumer.start();
+
+ }
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo16ThreadandLambda/WaitingAndNotify/ThreadsCorrepondence.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo16ThreadandLambda/WaitingAndNotify/ThreadsCorrepondence.java"
new file mode 100644
index 0000000..be5923d
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo16ThreadandLambda/WaitingAndNotify/ThreadsCorrepondence.java"
@@ -0,0 +1,51 @@
+package demo16ThreadandLambda.WaitingAndNotify;
+
+/*
+ 等待唤醒案例:线程之间的通信
+ 创建一个顾客线程(consumer):告知老板包子的数量和种类,调用wait()方法进入waiting状态
+ 创建一个老板线程(productor):画五秒时间做包子,做好调用notify()方法通知顾客吃包子
+ 注意:
+ 顾客和老板线程必须使用同步代码块包裹起来,
+ 同步对象使用的锁必须一致
+ 只有锁对象才能调用wait()和notify()方法
+ */
+public class ThreadsCorrepondence {
+ public static void main(String[] args) {
+ //创建锁对象
+ Object obj=new Object();
+ //创建顾客线程
+ new Thread(){
+ @Override
+ public void run() {
+ synchronized (obj){
+ System.out.println("告知老板索要包子的数量和种类");
+ try {
+ obj.wait(5000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ System.out.println("包子已经做好了,开吃");
+ }
+ }
+ }.start();
+ //创建老板线程
+ new Thread(){
+ @Override
+ public void run() {
+
+ synchronized (obj){
+ System.out.println("老板告诉顾客五秒钟后做好包子,请等待");
+ try {
+ for (int i = 5; i>0 ; i--) {
+ System.out.println(i);
+ Thread.sleep(1000);
+ }
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ //obj.notify();
+ }
+ }
+ }.start();
+ }
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo17File/Demo01File.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo17File/Demo01File.java"
new file mode 100644
index 0000000..734a79e
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo17File/Demo01File.java"
@@ -0,0 +1,38 @@
+package demo17File;
+
+import java.io.File;
+
+/*
+.* `public String getAbsolutePath() ` :返回此File的绝对路径名字符串。
+* ` public String getPath() ` :将此File转换为路径名字符串。
+* `public String getName()` :返回由此File表示的文件或目录的名称。
+* `public long length()` :返回由此File表示的文件的长度,以字节为单位。
+
+ public boolean exists()` :此File表示的文件或目录是否实际存在。
+ 是:true;
+ 否:false
+ public boolean isDirectory()` :此File表示的是否为目录。
+ 用于判断构造方法中给定的路径是否是以文件夹结尾的
+ 是:true;
+ 否:false;
+ public boolean isFile()` :此File表示的是否为文件。
+ 用于判断用于判断构造方法中给定的路径是否是以文件结尾的
+ */
+public class Demo01File {
+ public static void main(String[] args) {
+ File f1=new File("F:\\JavaStudy\\基础语法\\src\\demo17File\\Demo01File.java");
+ System.out.println(f1.getAbsoluteFile());
+ System.out.println(f1.getName());
+ System.out.println(f1.length());
+ System.out.println(f1.getPath());
+ System.out.println(f1.exists());
+ System.out.println(f1.isFile());
+ System.out.println(f1.isDirectory());
+
+ File f2=new File("F:\\JavaStudy\\基础语法\\src\\demo17File");
+ System.out.println(f2.isDirectory());
+ System.out.println(f2.isFile());
+
+
+ }
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo17File/Demo02File.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo17File/Demo02File.java"
new file mode 100644
index 0000000..51ee8bb
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo17File/Demo02File.java"
@@ -0,0 +1,34 @@
+package demo17File;
+
+import java.io.File;
+import java.io.IOException;
+
+/*
+- `public boolean createNewFile()` 当且仅当具有该名称的文件尚不存在时,创建一个新的空文件。
+- `public boolean delete()` :删除由此File表示的文件或目录。
+- `public boolean mkdir()` :创建由此File表示的目录。
+- `public boolean mkdirs()` :创建由此File表示的目录,包括任何必需但不存在的父目录
+ */
+public class Demo02File {
+ public static void main(String[] args) {
+ File f1 = new File("G:\\a.txt");
+ System.out.println(f1.getName());
+ if (!f1.exists()) {
+ try {
+ f1.createNewFile();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ System.out.println(f1.getPath());
+ if (f1.exists()) {
+ f1.delete();
+ }
+
+ File f2 = new File("G:\\newfile");
+ System.out.println(f2.mkdir());
+ File f3=new File("G:\\news\\paper");
+ System.out.println(f3.mkdirs());
+
+ }
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo17File/Demo03FIle.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo17File/Demo03FIle.java"
new file mode 100644
index 0000000..35e174b
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo17File/Demo03FIle.java"
@@ -0,0 +1,22 @@
+package demo17File;
+
+import java.io.File;
+
+public class Demo03FIle {
+ public static void main(String[] args) {
+ File file=new File("F:\\JavaStudy\\基础语法\\src");
+ String [] filelist=file.list();
+ for (String filename:filelist
+ ) {
+ System.out.println(filename);
+
+ }
+ File [] files=file.listFiles();
+ for (File filename:files
+ ) {
+ System.out.println(filename);
+ }
+ int []arr=new int[3];
+ System.out.println(arr[0]);
+ }
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo17File/Demo4File.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo17File/Demo4File.java"
new file mode 100644
index 0000000..46b910f
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo17File/Demo4File.java"
@@ -0,0 +1,25 @@
+package demo17File;
+
+import java.io.File;
+
+public class Demo4File {
+ public static void main(String[] args) {
+ File file=new File("F:\\JavaStudy\\基础语法\\src\\demo12");
+ getAllDerictory(file);
+ }
+ public static void getAllDerictory(File file)
+ {
+ System.out.println(file);
+ File []files=file.listFiles();//获得file目录下所有子文件或者子目录
+ for(File f:files){
+ if(f.isDirectory()){//如果是文件夹可以继续递归遍历
+ getAllDerictory(f);
+ }
+ else
+ {
+ System.out.println(f.getAbsolutePath());//如果不是打印文件绝对路径
+ }
+ }
+
+ }
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo19Buffered/BufferedInputStream/BufferedInputStreamTest.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo19Buffered/BufferedInputStream/BufferedInputStreamTest.java"
new file mode 100644
index 0000000..628f8ab
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo19Buffered/BufferedInputStream/BufferedInputStreamTest.java"
@@ -0,0 +1,53 @@
+package demo19Buffered.BufferedInputStream;
+
+import java.io.BufferedInputStream;
+import java.io.FileInputStream;
+import java.io.IOException;
+
+/*
+ java.io.BufferedInputStream extends InputStream
+ BufferedInputStream:字节缓冲输入流
+
+ 继承自父类的成员方法:
+ int read()从输入流中读取数据的下一个字节。
+ int read(byte[] b) 从输入流中读取一定数量的字节,并将其存储在缓冲区数组 b 中。
+ void close() 关闭此输入流并释放与该流关联的所有系统资源。
+
+ 构造方法:
+ BufferedInputStream(InputStream in) 创建一个使用默认大小的输入缓冲区的字节缓冲输出流。
+ BufferedInputStream(InputStream in, int size) 创建具有指定缓冲区大小的 BufferedInputStream 并保存其参数,即输入流 in,以便将来使用。
+ 参数:
+ InputStream in:字节输入流
+ 我们可以传递FileInputStream,缓冲流会给FileInputStream增加一个缓冲区,提高FileInputStream的读取效率
+ int size:指定缓冲流内部缓冲区的大小,不指定默认
+
+ 使用步骤(重点):
+ 1.创建FileInputStream对象,构造方法中绑定要读取的数据源
+ 2.创建BufferedInputStream对象,构造方法中传递FileInputStream对象,提高FileInputStream对象的读取效率
+ 3.使用BufferedInputStream对象中的方法read,读取文件
+ 4.释放资源
+ */
+public class BufferedInputStreamTest {
+ public static void main(String[] args) throws IOException {
+ //1.创建FileInputStream对象,构造方法中绑定要读取的数据源
+ FileInputStream fis = new FileInputStream("F:\\JavaStudy\\基础语法\\src\\demo19Buffered\\BufferedOutputStream\\a.txt");
+ //2.创建BufferedInputStream对象,构造方法中传递FileInputStream对象,提高FileInputStream对象的读取效率
+ BufferedInputStream bis = new BufferedInputStream(fis);
+ //3.使用BufferedInputStream对象中的方法read,读取文件
+ //int read()从输入流中读取数据的下一个字节。
+ /*int len = 0;//记录每次读取到的字节
+ while((len = bis.read())!=-1){
+ System.out.println(len);
+ }*/
+
+ //int read(byte[] b) 从输入流中读取一定数量的字节,并将其存储在缓冲区数组 b 中。
+ byte[] bytes =new byte[1024];//存储每次读取的数据
+ int len = 0; //记录每次读取的有效字节个数
+ while((len = bis.read(bytes))!=-1){
+ System.out.println(new String(bytes,0,len));
+ }
+
+ //4.释放资源
+ bis.close();
+ }
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo19Buffered/BufferedInputStream/a.txt" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo19Buffered/BufferedInputStream/a.txt"
new file mode 100644
index 0000000..3f62182
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo19Buffered/BufferedInputStream/a.txt"
@@ -0,0 +1 @@
+hinata
\ No newline at end of file
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo19Buffered/BufferedOutputStream/BufferedOutputStreamTest.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo19Buffered/BufferedOutputStream/BufferedOutputStreamTest.java"
new file mode 100644
index 0000000..335c45b
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo19Buffered/BufferedOutputStream/BufferedOutputStreamTest.java"
@@ -0,0 +1,39 @@
+package demo19Buffered.BufferedOutputStream;
+/*
+ BufferedOutputStream字节缓冲输出流
+ 继承自父类的共性成员方法:
+ - public void close() :关闭此输出流并释放与此流相关联的任何系统资源。
+ - public void flush() :刷新此输出流并强制任何缓冲的输出字节被写出。
+ - public void write(byte[] b):将 b.length字节从指定的字节数组写入此输出流。
+ - public void write(byte[] b, int off, int len) :从指定的字节数组写入 len字节,从偏移量 off开始输出到此输出流。
+ - public abstract void write(int b) :将指定的字节输出流。
+
+ 构造方法:
+ BufferedOutputStream(OutputStream out) 创建一个新的缓冲输出流,以将数据写入指定的底层输出流。
+ BufferedOutputStream(OutputStream out, int size) 创建一个新的缓冲输出流,以将具有指定缓冲区大小的数据写入指定的底层输出流。
+ 参数:
+ OutputStream out:字节输出流
+ 我们可以传递FileOutputStream,缓冲流会给FileOutputStream增加一个缓冲区,提高FileOutputStream的写入效率
+ int size:指定缓冲流内部缓冲区的大小,不指定默认
+ 使用步骤(重点)
+ 1.创建FileOutputStream对象,构造方法中绑定要输出的目的地
+ 2.创建BufferedOutputStream对象,构造方法中传递FileOutputStream对象对象,提高FileOutputStream对象效率
+ 3.使用BufferedOutputStream对象中的方法write,把数据写入到内部缓冲区中
+ 4.使用BufferedOutputStream对象中的方法flush,把内部缓冲区中的数据,刷新到文件中
+ 5.释放资源(会先调用flush方法刷新数据,第4部可以省略)
+ */
+
+import java.io.BufferedOutputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+public class BufferedOutputStreamTest {
+ public static void main(String[] args) throws IOException {
+ FileOutputStream fos=new FileOutputStream("F:\\JavaStudy\\基础语法\\src\\demo19Buffered\\BufferedOutputStream\\a.txt");
+ BufferedOutputStream bos=new BufferedOutputStream(fos);
+ bos.write("hinata".getBytes());
+ bos.flush();//将数据从缓冲区刷新到文件
+ bos.close();
+
+ }
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo19Buffered/BufferedOutputStream/a.txt" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo19Buffered/BufferedOutputStream/a.txt"
new file mode 100644
index 0000000..3f62182
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo19Buffered/BufferedOutputStream/a.txt"
@@ -0,0 +1 @@
+hinata
\ No newline at end of file
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo19Buffered/BufferedReader/BufferedReaderWriter.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo19Buffered/BufferedReader/BufferedReaderWriter.java"
new file mode 100644
index 0000000..152e329
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo19Buffered/BufferedReader/BufferedReaderWriter.java"
@@ -0,0 +1,29 @@
+package demo19Buffered.BufferedReader;
+
+import java.io.*;
+import java.util.HashMap;
+
+public class BufferedReaderWriter {
+ public static void main(String[] args) throws IOException {
+ HashMap hashmap=new HashMap();//创建map集合存储序号和与之对应的段落文字
+ BufferedReader br=new BufferedReader(new FileReader("出师表.txt"));//创建字符缓冲输入流对象,读取原文件
+ BufferedWriter bw=new BufferedWriter(new FileWriter("out_出师表.txt"));//创建字符缓冲流,将排好序的文本写入out_出师表文件
+
+ String line=null;
+ while((line=br.readLine())!=null){
+ String [] split=line.split("\\.");//以"."为标志分割字符串,分割为两个String类型的数组
+ hashmap.put(split[0],split[1]);//将序号和对应的文本存入hashmap集合中;
+ }
+ br.close();//关闭字符缓冲输入流,释放资源
+ for(int i=1;i<=hashmap.size();i++){ + String key=String.valueOf(i); + bw.write(key+"."+hashmap.get(key)); + bw.newLine(); + } + // bw.flush() + bw.close(); + + + + } +} diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo19Buffered/BufferedWriter/BufferedWriterTest.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo19Buffered/BufferedWriter/BufferedWriterTest.java" new file mode 100644 index 0000000..86862e1 --- /dev/null +++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo19Buffered/BufferedWriter/BufferedWriterTest.java" @@ -0,0 +1,47 @@ +package demo19Buffered.BufferedWriter; + +import java.io.BufferedWriter; +import java.io.FileWriter; +import java.io.IOException; + +/* + java.io.BufferedWriter extends Writer + BufferedWriter:字符缓冲输出流 + + 继承自父类的共性成员方法: + - void write(int c) 写入单个字符。 + - void write(char[] cbuf)写入字符数组。 + - abstract void write(char[] cbuf, int off, int len)写入字符数组的某一部分,off数组的开始索引,len写的字符个数。 + - void write(String str)写入字符串。 + - void write(String str, int off, int len) 写入字符串的某一部分,off字符串的开始索引,len写的字符个数。 + - void flush()刷新该流的缓冲。 + - void close() 关闭此流,但要先刷新它。 + + 构造方法: + BufferedWriter(Writer out) 创建一个使用默认大小输出缓冲区的缓冲字符输出流。 + BufferedWriter(Writer out, int sz) 创建一个使用给定大小输出缓冲区的新缓冲字符输出流。 + 参数: + Writer out:字符输出流 + 我们可以传递FileWriter,缓冲流会给FileWriter增加一个缓冲区,提高FileWriter的写入效率 + int sz:指定缓冲区的大小,不写默认大小 + + 特有的成员方法: + void newLine() 写入一个行分隔符。会根据不同的操作系统,获取不同的行分隔符 + 换行:换行符号 + windows:\r\n + linux:/n + mac:/r + 使用步骤: + 1.创建字符缓冲输出流对象,构造方法中传递字符输出流 + 2.调用字符缓冲输出流中的方法write,把数据写入到内存缓冲区中 + 3.调用字符缓冲输出流中的方法flush,把内存缓冲区中的数据,刷新到文件中 + 4.释放资源 + */ +public class BufferedWriterTest { + public static void main(String[] args) throws IOException { + BufferedWriter bw=new BufferedWriter(new FileWriter("出师表.txt")); + bw.write("诸葛亮"); + bw.flush(); + bw.close(); + } +} diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo20InputStreamReaderOutputStreamReader/Test.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo20InputStreamReaderOutputStreamReader/Test.java" new file mode 100644 index 0000000..ff4c714 --- /dev/null +++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo20InputStreamReaderOutputStreamReader/Test.java" @@ -0,0 +1,60 @@ +package demo20InputStreamReaderOutputStreamReader; + +import java.io.*; + +/* + 转换流 java.io.OutputtreamWriter ,是writer的子类,是从字节流到字符流的桥梁。它读取字节,并使用指定 + 的字符集将其解码为字符。它的字符集可以由名称指定,也可以接受平台的默认字符集。 + 编码过程:把能看懂的变成看不懂的 + 构造方法: + 1.OutputStreamWriter(OutputStream in) : 创建一个使用默认字符集的字符流。 + 2.OutputStreamWriter(OutputStream in, String charsetName) : 创建一个指定字符集的字符流 + 使用步骤: + 1.创建一个OutputStreamwriter对象,构造方法中传递传入字节输出流和编码集名称 + 2.使用OutputStreamWriter对象中的write()方法,把制定编码集的字符转化为字节,并存入缓冲区 + 3.使用OutputStreamWriter中方法flush()方法把缓冲区的字节刷新到文件中 + 4.释放资源 + + 转换流 java.io.InputStreamReader ,是Reader的子类,是从字节流到字符流的桥梁。它读取字节,并使用指定 + 的字符集将其解码为字符。它的字符集可以由名称指定,也可以接受平台的默认字符集。 + */ +public class Test { + public static void main(String[] args) throws IOException{ + write_uft_8(); + write_gbk(); + reade_utf_8(); + reade_gbk(); + } + + private static void reade_gbk()throws IOException { + InputStreamReader isr=new InputStreamReader(new FileInputStream("gbk.txt"),"gbk"); + int len; + while((len=isr.read())!=-1){ + System.out.println((char)len); + } + isr.close(); + } + + private static void reade_utf_8() throws IOException{ + InputStreamReader isr=new InputStreamReader(new FileInputStream("utf_8.txt"),"utf-8"); + int len; + while((len=isr.read())!=-1){ + System.out.println((char)len); + } + isr.close(); + } + + private static void write_gbk() throws IOException{ + OutputStreamWriter osw=new OutputStreamWriter(new FileOutputStream("gbk.txt"),"gbk"); + osw.write("gbk你好"); + osw.flush(); + osw.close(); + } + + private static void write_uft_8() throws IOException { + OutputStreamWriter osw=new OutputStreamWriter(new FileOutputStream("utf_8.txt"),"utf-8"); + osw.write("你好"); + osw.flush(); + osw.close(); + } +} diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo21/Serializable/ObjectInputStream/ObjectInputstreamTest.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo21/Serializable/ObjectInputStream/ObjectInputstreamTest.java" new file mode 100644 index 0000000..fc08eca --- /dev/null +++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo21/Serializable/ObjectInputStream/ObjectInputstreamTest.java" @@ -0,0 +1,16 @@ +package demo21.Serializable.ObjectInputStream; + +import java.io.FileInputStream; +import java.io.IOException; +import java.io.ObjectInputStream; + +public class ObjectInputstreamTest { + public static void main(String[] args) throws IOException, ClassNotFoundException { + ObjectInputStream ois=new ObjectInputStream(new FileInputStream("out.txt")); + Object o=ois.readObject(); + ois.close(); + System.out.println(o); + + + } +} diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo21/Serializable/ObjectOutputStream/ObjectOutputStreamTest.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo21/Serializable/ObjectOutputStream/ObjectOutputStreamTest.java" new file mode 100644 index 0000000..7187394 --- /dev/null +++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo21/Serializable/ObjectOutputStream/ObjectOutputStreamTest.java" @@ -0,0 +1,13 @@ +package demo21.Serializable.ObjectOutputStream; + +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.ObjectOutputStream; + +public class ObjectOutputStreamTest { + public static void main(String[] args) throws IOException { + ObjectOutputStream oos=new ObjectOutputStream(new FileOutputStream("out.txt")); + oos.writeObject(new Person("贾国胜",22)); + oos.close(); + } +} diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo21/Serializable/ObjectOutputStream/Person.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo21/Serializable/ObjectOutputStream/Person.java" new file mode 100644 index 0000000..cc38dc1 --- /dev/null +++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo21/Serializable/ObjectOutputStream/Person.java" @@ -0,0 +1,41 @@ +package demo21.Serializable.ObjectOutputStream; + +import java.io.Serializable; + +public class Person implements Serializable { + private static final long serialVersionUID=1l; + private String name; + public int age; + + @Override + public String toString() { + return "Person{" + + "name='" + name + '\'' + + ", age=" + age + + '}'; + } + + public Person() { + } + + public Person(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; + } +} diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo21/Serializable/Test/Person.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo21/Serializable/Test/Person.java" new file mode 100644 index 0000000..762ceb2 --- /dev/null +++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo21/Serializable/Test/Person.java" @@ -0,0 +1,41 @@ +package demo21.Serializable.Test; + +import java.io.Serializable; + +public class Person implements Serializable { + private static final long serialVersionUID=1l; + private String name; + public int age; + + @Override + public String toString() { + return "Person{" + + "name='" + name + '\'' + + ", age=" + age + + '}'; + } + + public Person() { + } + + public Person(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; + } +} diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo21/Serializable/Test/Test.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo21/Serializable/Test/Test.java" new file mode 100644 index 0000000..9aa6024 --- /dev/null +++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo21/Serializable/Test/Test.java" @@ -0,0 +1,22 @@ +package demo21.Serializable.Test; + +import java.io.*; +import java.util.ArrayList; +import java.util.List; + +public class Test { + public static void main(String[] args) throws IOException, ClassNotFoundException { + List list=new ArrayList();
+ ObjectOutputStream oos=new ObjectOutputStream(new FileOutputStream("out_test.txt"));
+ list.add(new Person("贾国胜",22));
+ list.add(new Person("hinata",16));
+ list.add(new Person("naruto",16));
+ oos.writeObject(list);
+
+ //反序列化
+ ObjectInputStream ois=new ObjectInputStream(new FileInputStream("out_test.txt"));
+ ArrayList arraylist=(ArrayList)ois.readObject();
+ for(int i=0;i{
+ System.out.println("使用Lambda表达式重写函数式接口");
+ });
+
+ }
+ public static void show(MyFunctionalInterface myFunctionalInterface){
+ myFunctionalInterface.method();
+ }
+
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo23FunctionalInterface/Lambda01/Demo02Lambda.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo23FunctionalInterface/Lambda01/Demo02Lambda.java"
new file mode 100644
index 0000000..02c619c
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo23FunctionalInterface/Lambda01/Demo02Lambda.java"
@@ -0,0 +1,31 @@
+package demo23FunctionalInterface.Lambda01;
+/*
+
+ */
+public class Demo02Lambda {
+ public static void main(String[] args) {
+ //定义三个日志xinx
+ String msg1="Hello";
+ String msg2="World";
+ String msg3="Java";
+ //调用shoLog方法
+ showLog(1,()->{
+ return msg1+msg2+msg3;
+ });
+ /*
+ 使用lambda表达式作为参数传递,仅仅是把参数传递到show方法中,只有满足条件才会进行字符串的拼接
+ 如果不满足,即日子等级不是1,messageBuilder也不会执行,
+ 不存在性能浪费
+
+ */
+
+ }
+ //定义一个显示日志的方法 ,方法的参数传递日志等级和函数式接口MessageBuilder
+ public static void showLog(int leval,MessageBuilder mb){
+ //对日志的等级进行判断
+ if(leval==1){
+ System.out.println(mb.builderMessage()) ;
+ }
+ }
+
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo23FunctionalInterface/Lambda01/MessageBuilder.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo23FunctionalInterface/Lambda01/MessageBuilder.java"
new file mode 100644
index 0000000..bf30025
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo23FunctionalInterface/Lambda01/MessageBuilder.java"
@@ -0,0 +1,6 @@
+package demo23FunctionalInterface.Lambda01;
+@FunctionalInterface
+public interface MessageBuilder {
+ public abstract String builderMessage();
+
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo23FunctionalInterface/Lambda02/DemoComparator.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo23FunctionalInterface/Lambda02/DemoComparator.java"
new file mode 100644
index 0000000..ebe431e
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo23FunctionalInterface/Lambda02/DemoComparator.java"
@@ -0,0 +1,16 @@
+package demo23FunctionalInterface.Lambda02;
+
+import java.util.Arrays;
+import java.util.Comparator;
+
+public class DemoComparator {
+ public static ComparatorgetCompare(){
+ return (s1,s2)->s2.length()-s1.length();
+ }
+ public static void main(String[] args) {
+ String []arr={"123","1234","12345","1234566"};
+ System.out.println(Arrays.toString(arr));
+ Arrays.sort(arr,getCompare());
+ System.out.println(Arrays.toString(arr));
+ }
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo23FunctionalInterface/Lambda03/Demo.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo23FunctionalInterface/Lambda03/Demo.java"
new file mode 100644
index 0000000..86a98d6
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo23FunctionalInterface/Lambda03/Demo.java"
@@ -0,0 +1,143 @@
+package demo23FunctionalInterface.Lambda03;
+
+import java.util.function.Consumer;
+import java.util.function.Function;
+import java.util.function.Predicate;
+import java.util.function.Supplier;
+
+/*
+ 常用的函数式接口
+
+ */
+public class Demo {
+ public static int getInteger(Supplier supplier){
+ return supplier.get();
+ }
+ public static void method(String name, Consumer consumer){
+ consumer.accept(name);
+ }
+ public static void method(String name,Consumer con1,Consumer con2){
+ /* con1.accept(name);
+ con2.accept(name);*/
+ con1.andThen(con2).accept(name);
+ }
+
+ public static void pringInformation(String []arr,Consumer con1,Consumer con2){
+ for (String str:arr) {
+ con1.andThen(con2).accept(str);
+ }
+ }
+ /*
+ java.util.function.Predicate接口
+ 作用:对某种数据类型的数据进行判断,结果返回一个boolean值
+ */
+ /*
+ 定义一个方法
+ 参数传递一个String 类型的字符串
+ 传递一个Predicate类型的接口,泛型使用String
+ 使用Predicate中的test()方法对字符窜的长度进行判断、
+ */
+ public static boolean judgeTest(String str, Predicate predicate){
+ return predicate.test(str);
+ }
+ /*
+ predicate接口中有一个and()方法表示逻辑与 可以连接两个判断条件
+ 方法内部两个判断条件也是使用&&云算法连接起来的
+ 定义一个方法,方法传递一个字符串String str
+ 传递两个predicate 接口:
+ 一个用于判断字符串的长度是否大于5
+ 一个用于判断字符串中是否包含"贾国胜"
+ */
+ public static boolean andTest(String str,Predicatepd1,Predicatepd2){
+ return pd1.and(pd2).test(str);
+ }
+ /*
+ Predicate接口中有一个or()方法表示逻辑或者 可以连接两个判断条件
+ 方法内部两个判断条件也是使用||运算符连接起来的
+ 定义一个方法,方法传递一个字符串String str
+ 传递两个predicate 接口:
+ 一个用于判断字符串的长度是否大于5
+ 一个用于判断字符串中是否包含"贾国胜"
+ */
+ public static boolean orTest(String str,Predicate pd1,Predicatepd2){
+ return pd1.or(pd2).test(str);
+ }
+ /*
+ Predicate接口中有一个negate()方法表示逻辑取反
+ 定义一个方法,方法传递一个字符串String str
+ 传递一个predicate 接口:
+ 一个用于判断字符串的长度是否大于5
+ */
+ public static boolean negateTest(String str,Predicate predicate){
+ return predicate.negate().test(str);
+ }
+ /*
+ java.util.function.Function 接口用来根据一个类型的数据得到另一个类型的数据,前者称为前置条件,
+ 后者称为后置条件
+ */
+ /*
+ Function接口中有一个方法R apply(T,t)根据类型T 的参数获取类型R的结果
+ 使用场景:将String 类型转换为Integer类型
+
+ */
+ public static void StringToInterge(String str, Function fun){
+ Integer integer=fun.apply(str);
+ System.out.println(integer);
+ }
+
+ public static void andthenTest(String str, Function fun1, Functionfun2){
+ String s= fun1.andThen(fun2).apply(str);
+ System.out.println(s);
+ }
+ public static void main(String[] args) {
+ /*
+ Supplier接口:接口仅包含一个无参的方法:get() 。用来获取一个泛型参数指定类型的对
+ 象数据。由于这是一个函数式接口,这也就意味着对应的Lambda表达式需要"对外提供"一个符合泛型类型的对象
+ 数据
+ */
+ int []arr=new int[]{1,2,3,55,-44,18,144,90};
+ int ans=getInteger(()->{
+ int max=arr[0];
+ for(int i=1;i{String rename=new StringBuffer(name).reverse().toString();
+ System.out.println(rename);
+ });
+ method("贾国胜",(String name)-> System.out.println(name),(String name)-> {
+ String rename = new StringBuffer(name).reverse().toString();
+ System.out.println(rename);
+ });
+
+ String [] array={"hinata,女","naruto,男","佐助,男"};
+ pringInformation(array, s-> System.out.println("姓名:"+s.split(",")[0]),
+ s-> System.out.println("性别:"+s.split(",")[1]));
+
+ System.out.println(judgeTest("贾国胜",(String name)->{return name.length()>5;}));
+
+ System.out.println(andTest("贾国胜是吉林大学的学生",strinfo->strinfo.length()>5,strinfo->strinfo.contains("贾国胜")));
+
+ System.out.println(orTest("国胜今年22岁了",strinfo->strinfo.length()>5,striifno->striifno.contains("贾国胜")));
+
+ System.out.println(negateTest("贾国胜",strinfo->strinfo.length()>5));
+
+ StringToInterge("12345",s->Integer.parseInt(s));
+ andthenTest("1234",(String str)->{
+ int num=Integer.parseInt(str);
+ num+=100;
+ return num;
+ },(Integer i)->{
+ return i+"";
+ });
+ }
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo23FunctionalInterface/MyFunctionalInterface.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo23FunctionalInterface/MyFunctionalInterface.java"
new file mode 100644
index 0000000..fb3b0f6
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo23FunctionalInterface/MyFunctionalInterface.java"
@@ -0,0 +1,13 @@
+package demo23FunctionalInterface;
+
+
+/*
+ 函数式接口:有且仅有一个抽象方法的接口
+ 作用:一般用作方法的参数和返回值
+
+ */
+@FunctionalInterface //注解:标志此类是函数式接口
+public interface MyFunctionalInterface {
+ public abstract void method();
+
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo23FunctionalInterface/MyFunctionalInterfaceImpl.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo23FunctionalInterface/MyFunctionalInterfaceImpl.java"
new file mode 100644
index 0000000..a8a5ed0
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo23FunctionalInterface/MyFunctionalInterfaceImpl.java"
@@ -0,0 +1,10 @@
+package demo23FunctionalInterface;
+
+public class MyFunctionalInterfaceImpl implements MyFunctionalInterface {
+ @Override
+ public void method() {
+ System.out.println("继承了函数式接口");
+ }
+
+
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo24Stream/ArrayMethodReference/ArrayBuillder.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo24Stream/ArrayMethodReference/ArrayBuillder.java"
new file mode 100644
index 0000000..86f8881
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo24Stream/ArrayMethodReference/ArrayBuillder.java"
@@ -0,0 +1,6 @@
+package demo24Stream.ArrayMethodReference;
+@FunctionalInterface
+public interface ArrayBuillder {
+ public abstract int [] arrayBuilder(int length);
+
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo24Stream/ArrayMethodReference/DemoTest.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo24Stream/ArrayMethodReference/DemoTest.java"
new file mode 100644
index 0000000..a94cdc8
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo24Stream/ArrayMethodReference/DemoTest.java"
@@ -0,0 +1,12 @@
+package demo24Stream.ArrayMethodReference;
+
+public class DemoTest {
+ public static int [] getArray(int length,ArrayBuillder ab){
+ return ab.arrayBuilder(length);
+ }
+
+ public static void main(String[] args) {
+ int [] array=getArray(5, int []::new);
+ System.out.println(array.length);
+ }
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo24Stream/ConstructorMethodReference/DemoTest.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo24Stream/ConstructorMethodReference/DemoTest.java"
new file mode 100644
index 0000000..122662d
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo24Stream/ConstructorMethodReference/DemoTest.java"
@@ -0,0 +1,12 @@
+package demo24Stream.ConstructorMethodReference;
+
+public class DemoTest {
+ public static Person getPresonObject(String str,PersonBuilder pb){
+ return pb.personBuilder(str);
+ }
+ //注意:静态方法只能调用静态方法
+ public static void main(String[] args) {
+ Person person=getPresonObject("贾国胜",Person::new);
+ System.out.println(person);
+ }
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo24Stream/ConstructorMethodReference/Person.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo24Stream/ConstructorMethodReference/Person.java"
new file mode 100644
index 0000000..33531b6
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo24Stream/ConstructorMethodReference/Person.java"
@@ -0,0 +1,24 @@
+package demo24Stream.ConstructorMethodReference;
+
+public class Person {
+ private String name;
+ public Person(){
+
+ }
+ public Person(String name){
+ this.name=name;
+ }
+ public void setName(String name){
+ this.name=name;
+ }
+ public String getName(){
+ return this.name;
+ }
+
+ @Override
+ public String toString() {
+ return "Person{" +
+ "name='" + name + '\'' +
+ '}';
+ }
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo24Stream/ConstructorMethodReference/PersonBuilder.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo24Stream/ConstructorMethodReference/PersonBuilder.java"
new file mode 100644
index 0000000..fc08984
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo24Stream/ConstructorMethodReference/PersonBuilder.java"
@@ -0,0 +1,5 @@
+package demo24Stream.ConstructorMethodReference;
+@FunctionalInterface
+public interface PersonBuilder {
+ public abstract Person personBuilder(String name);
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo24Stream/Demo.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo24Stream/Demo.java"
new file mode 100644
index 0000000..6af0c6a
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo24Stream/Demo.java"
@@ -0,0 +1,15 @@
+package demo24Stream;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class Demo {
+ public static void main(String[] args) {
+ List list =new ArrayList();
+ list.add("周芷若");
+ list.add("张无忌");
+ list.add("赵敏");
+ list.add("张三丰");
+ list.stream().filter(name->name.startsWith("张")).filter(name->name.length()==3).forEach(name-> System.out.println(name));
+ }
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo24Stream/DemoGetStream.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo24Stream/DemoGetStream.java"
new file mode 100644
index 0000000..05d6a3d
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo24Stream/DemoGetStream.java"
@@ -0,0 +1,37 @@
+package demo24Stream;
+
+import java.util.*;
+import java.util.stream.Stream;
+
+/*
+ java.util.stream.Stream 是Java 8新加入的最常用的流接口。(这并不是一个函数式接口。)
+ 获取一个流非常简单,有以下几种常用的方式:
+ 所有的 Collection 集合都可以通过 stream 默认方法获取流;
+ Stream 接口的静态方法 of 可以获取数组对应的流。
+ static Stream of(T...value)
+ 参数 是一个可变参数,数组
+ */
+public class DemoGetStream {
+ public static void main(String[] args) {
+ List list=new ArrayList();
+ Stream streamlist=list.stream();
+ Set set=new HashSet();
+ Stream streamset=set.stream();
+ Vector vector=new Vector();
+ Stream streamvector=vector.stream();
+ /*
+
+ */
+ Streamstream=Stream.of("1","2","3");
+
+ Stream streaminteger=stream.map(num->Integer.parseInt(num));
+ ;
+ Stream streamskip=streaminteger.skip(1);
+ streamskip.forEach(num-> System.out.println(num));
+
+
+
+
+
+ }
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo24Stream/MethodReference/Demo01Printable.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo24Stream/MethodReference/Demo01Printable.java"
new file mode 100644
index 0000000..95e9c46
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo24Stream/MethodReference/Demo01Printable.java"
@@ -0,0 +1,14 @@
+package demo24Stream.MethodReference;
+
+public class Demo01Printable {
+ //定义一个方法,参数传递Printabe接口
+ public static void printString(Printable p){
+ p.print("HelloWorld");
+ }
+ public static void main(String[] args) {
+ //lambda表达式写法
+ // printString(name-> System.out.println(name));
+ // 方法引用写法,这种写法代替了lambda表达式
+ printString(System.out::println);
+ }
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo24Stream/MethodReference/Printable.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo24Stream/MethodReference/Printable.java"
new file mode 100644
index 0000000..9e27c80
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo24Stream/MethodReference/Printable.java"
@@ -0,0 +1,11 @@
+package demo24Stream.MethodReference;
+
+
+/*
+ 定义一个函数式接口
+ */
+@FunctionalInterface
+public interface Printable {
+ public abstract void print(String str);
+
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo24Stream/ObjectMethodReferencee/MethodRefenceObject.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo24Stream/ObjectMethodReferencee/MethodRefenceObject.java"
new file mode 100644
index 0000000..9cbd117
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo24Stream/ObjectMethodReferencee/MethodRefenceObject.java"
@@ -0,0 +1,8 @@
+package demo24Stream.ObjectMethodReferencee;
+
+public class MethodRefenceObject {
+ //
+ public void printUpperCaseString(String str){
+ System.out.println(str.toUpperCase());
+ }
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo24Stream/ObjectMethodReferencee/Printable.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo24Stream/ObjectMethodReferencee/Printable.java"
new file mode 100644
index 0000000..42e1cbb
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo24Stream/ObjectMethodReferencee/Printable.java"
@@ -0,0 +1,11 @@
+package demo24Stream.ObjectMethodReferencee;
+
+
+/*
+ 定义一个函数式接口
+ */
+@FunctionalInterface
+public interface Printable {
+ public abstract void print(String str);
+
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo24Stream/ObjectMethodReferencee/Test.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo24Stream/ObjectMethodReferencee/Test.java"
new file mode 100644
index 0000000..7812a3d
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo24Stream/ObjectMethodReferencee/Test.java"
@@ -0,0 +1,26 @@
+package demo24Stream.ObjectMethodReferencee;
+
+public class Test {
+ /*
+ 通过对象引用成员方法
+ 使用前提是对象名前提是对象名已经存在,成员方法也是已经存在的
+
+ */
+ public static void printString(Printable p){
+ p.print("helloworld");
+ }
+ public static void main(String[] args) {
+ /*
+ lambda表达式形式
+ */
+ printString((str)->{
+ MethodRefenceObject obj=new MethodRefenceObject();
+ obj.printUpperCaseString(str);
+ });
+ /*
+ 方法引用形式
+ */
+ MethodRefenceObject obj=new MethodRefenceObject();
+ printString(obj::printUpperCaseString);
+ }
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo24Stream/Person.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo24Stream/Person.java"
new file mode 100644
index 0000000..cd24bb4
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo24Stream/Person.java"
@@ -0,0 +1,27 @@
+package demo24Stream;
+
+public class Person {
+ private String name;
+
+ public Person(String name) {
+ this.name = name;
+ }
+ public Person(){
+
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String toString() {
+ return "Person{" +
+ "name='" + name + '\'' +
+ '}';
+ }
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo24Stream/Test.java" "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo24Stream/Test.java"
new file mode 100644
index 0000000..5959ec6
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/src/demo24Stream/Test.java"
@@ -0,0 +1,46 @@
+package demo24Stream;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Stream;
+
+public class Test {
+ //第一支队伍
+ public static void main(String[] args) {
+ List one=new ArrayList();
+ one.add("迪丽热巴");
+ one.add("宋远桥");
+ one.add("苏星河");
+ one.add("石破天");
+ one.add("石中玉");
+ one.add("老子");
+ one.add("庄子");
+ one.add("洪七公");
+ //第一个队伍只要名字为三个字的成员,存储到一个新的集合
+ // List newone=new ArrayList();
+ Stream streamone=one.stream().filter(name->name.length()==3).limit(3);
+
+ //第二个队伍
+ ArrayList two = new ArrayList();
+ two.add("古力娜扎");
+ two.add("张无忌");
+ two.add("赵丽颖");
+ two.add("张三丰");
+ two.add("尼古拉斯赵四");
+ two.add("张天爱");
+ two.add("张二狗");
+ //3. 第二个队伍只要姓张的成员姓名;存储到一个新集合中。
+ //ArrayList two1 = new ArrayList();
+ Stream streamtwo=two.stream().filter(name->name.startsWith("张")).skip(2);
+ Stream.concat(streamone,streamtwo).map(name->new Person(name)).forEach(person-> System.out.println(person));
+
+
+
+
+
+
+
+
+ }
+
+}
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/u=3221914326,2412238336&fm=26&gp=0.jpg" "b/345円237円272円347円241円200円350円257円255円346円263円225円/u=3221914326,2412238336&fm=26&gp=0.jpg"
new file mode 100644
index 0000000..cbb6b5f
Binary files /dev/null and "b/345円237円272円347円241円200円350円257円255円346円263円225円/u=3221914326,2412238336&fm=26&gp=0.jpg" differ
diff --git "a/345円237円272円347円241円200円350円257円255円346円263円225円/345円237円272円347円241円200円350円257円255円346円263円225円.iml" "b/345円237円272円347円241円200円350円257円255円346円263円225円/345円237円272円347円241円200円350円257円255円346円263円225円.iml"
new file mode 100644
index 0000000..37cc804
--- /dev/null
+++ "b/345円237円272円347円241円200円350円257円255円346円263円225円/345円237円272円347円241円200円350円257円255円346円263円225円.iml"
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git "a/350円277円233円351円230円266円350円257円255円346円263円225円/lib/c3p0-0.9.5.2.jar" "b/350円277円233円351円230円266円350円257円255円346円263円225円/lib/c3p0-0.9.5.2.jar"
new file mode 100644
index 0000000..579cedd
Binary files /dev/null and "b/350円277円233円351円230円266円350円257円255円346円263円225円/lib/c3p0-0.9.5.2.jar" differ
diff --git "a/350円277円233円351円230円266円350円257円255円346円263円225円/lib/commons-logging-1.2.jar" "b/350円277円233円351円230円266円350円257円255円346円263円225円/lib/commons-logging-1.2.jar"
new file mode 100644
index 0000000..93a3b9f
Binary files /dev/null and "b/350円277円233円351円230円266円350円257円255円346円263円225円/lib/commons-logging-1.2.jar" differ
diff --git "a/350円277円233円351円230円266円350円257円255円346円263円225円/lib/druid-1.0.9.jar" "b/350円277円233円351円230円266円350円257円255円346円263円225円/lib/druid-1.0.9.jar"
new file mode 100644
index 0000000..517dbc1
Binary files /dev/null and "b/350円277円233円351円230円266円350円257円255円346円263円225円/lib/druid-1.0.9.jar" differ
diff --git "a/350円277円233円351円230円266円350円257円255円346円263円225円/lib/mchange-commons-java-0.2.12.jar" "b/350円277円233円351円230円266円350円257円255円346円263円225円/lib/mchange-commons-java-0.2.12.jar"
new file mode 100644
index 0000000..af11054
Binary files /dev/null and "b/350円277円233円351円230円266円350円257円255円346円263円225円/lib/mchange-commons-java-0.2.12.jar" differ
diff --git "a/350円277円233円351円230円266円350円257円255円346円263円225円/lib/mysql-connector-java-5.1.37-bin.jar" "b/350円277円233円351円230円266円350円257円255円346円263円225円/lib/mysql-connector-java-5.1.37-bin.jar"
new file mode 100644
index 0000000..465af67
Binary files /dev/null and "b/350円277円233円351円230円266円350円257円255円346円263円225円/lib/mysql-connector-java-5.1.37-bin.jar" differ
diff --git "a/350円277円233円351円230円266円350円257円255円346円263円225円/lib/spring-beans-5.0.0.RELEASE.jar" "b/350円277円233円351円230円266円350円257円255円346円263円225円/lib/spring-beans-5.0.0.RELEASE.jar"
new file mode 100644
index 0000000..62a7cc6
Binary files /dev/null and "b/350円277円233円351円230円266円350円257円255円346円263円225円/lib/spring-beans-5.0.0.RELEASE.jar" differ
diff --git "a/350円277円233円351円230円266円350円257円255円346円263円225円/lib/spring-core-5.0.0.RELEASE.jar" "b/350円277円233円351円230円266円350円257円255円346円263円225円/lib/spring-core-5.0.0.RELEASE.jar"
new file mode 100644
index 0000000..77ff36d
Binary files /dev/null and "b/350円277円233円351円230円266円350円257円255円346円263円225円/lib/spring-core-5.0.0.RELEASE.jar" differ
diff --git "a/350円277円233円351円230円266円350円257円255円346円263円225円/lib/spring-jdbc-5.0.0.RELEASE.jar" "b/350円277円233円351円230円266円350円257円255円346円263円225円/lib/spring-jdbc-5.0.0.RELEASE.jar"
new file mode 100644
index 0000000..7d0f6e4
Binary files /dev/null and "b/350円277円233円351円230円266円350円257円255円346円263円225円/lib/spring-jdbc-5.0.0.RELEASE.jar" differ
diff --git "a/350円277円233円351円230円266円350円257円255円346円263円225円/lib/spring-tx-5.0.0.RELEASE.jar" "b/350円277円233円351円230円266円350円257円255円346円263円225円/lib/spring-tx-5.0.0.RELEASE.jar"
new file mode 100644
index 0000000..f5e67df
Binary files /dev/null and "b/350円277円233円351円230円266円350円257円255円346円263円225円/lib/spring-tx-5.0.0.RELEASE.jar" differ
diff --git "a/350円277円233円351円230円266円350円257円255円346円263円225円/src/c3p0-config.xml" "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/c3p0-config.xml"
new file mode 100644
index 0000000..bd38da5
--- /dev/null
+++ "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/c3p0-config.xml"
@@ -0,0 +1,28 @@
+
+
+
+
+ com.mysql.jdbc.Driver
+ jdbc:mysql://localhost:3306/db3
+ root
+ jiags1997
+
+
+ 5
+ 10
+ 3000
+
+
+
+
+ com.mysql.jdbc.Driver
+ jdbc:mysql://localhost:3306/db3
+ root
+ jiags1997
+
+
+ 5
+ 8
+ 1000
+
+
\ No newline at end of file
diff --git "a/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/annotation/AnnotationDemo1.java" "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/annotation/AnnotationDemo1.java"
new file mode 100644
index 0000000..501994c
--- /dev/null
+++ "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/annotation/AnnotationDemo1.java"
@@ -0,0 +1,23 @@
+package cn.edu.Jlu.Day01.annotation;
+
+import java.util.Date;
+
+public class AnnotationDemo1 {
+ @Override
+ public String toString(){
+ return super.toString();
+ }
+
+ @Deprecated
+ public void show01(){
+ //有缺陷
+ }
+ public void show02(){
+ //替代show01
+ }
+
+ public void dmeo(){
+ Date date=new Date();
+ }
+
+}
diff --git "a/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/annotation/AnnotationDemo2.java" "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/annotation/AnnotationDemo2.java"
new file mode 100644
index 0000000..fdda645
--- /dev/null
+++ "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/annotation/AnnotationDemo2.java"
@@ -0,0 +1,5 @@
+package cn.edu.Jlu.Day01.annotation;
+
+public class AnnotationDemo2 {
+
+}
diff --git "a/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/annotation/MyAnno.java" "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/annotation/MyAnno.java"
new file mode 100644
index 0000000..b817b00
--- /dev/null
+++ "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/annotation/MyAnno.java"
@@ -0,0 +1,26 @@
+package cn.edu.Jlu.Day01.annotation;
+
+public @interface MyAnno {
+ /*
+ 属性:注解中的成员方法叫做属性
+ 返回值类型要求:
+ 1.基本数据类型
+ 2.String
+ 3.枚举
+ 4.注解
+ 5.以上类型的数组
+ */
+ /*
+ 2. 定义了属性,在使用时需要给属性赋值
+ 1. 如果定义属性时,使用default关键字给属性默认初始化值,则使用注解时,可以不进行属性的赋值。
+ 2. 如果只有一个属性需要赋值,并且属性的名称是value,则value可以省略,直接定义值即可。
+ 3. 数组赋值时,值使用{}包裹。如果数组中只有一个值,则{}可以省略
+ */
+ //public abstract String getString();
+ int age();
+ String name() default "张三";
+ Person per();
+ MyAnno2 anno2();
+ String [] str();
+}
+
diff --git "a/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/annotation/MyAnno2.java" "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/annotation/MyAnno2.java"
new file mode 100644
index 0000000..c11068b
--- /dev/null
+++ "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/annotation/MyAnno2.java"
@@ -0,0 +1,5 @@
+package cn.edu.Jlu.Day01.annotation;
+
+public @interface MyAnno2 {
+
+}
diff --git "a/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/annotation/MyAnno3.java" "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/annotation/MyAnno3.java"
new file mode 100644
index 0000000..a2539c8
--- /dev/null
+++ "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/annotation/MyAnno3.java"
@@ -0,0 +1,25 @@
+package cn.edu.Jlu.Day01.annotation;
+
+
+import java.lang.annotation.*;
+
+/**
+ 元注解:用于描述注解的注解
+ * @Target:描述注解能够作用的位置
+ ElementType取值:
+ TYPE:可以作用于类上
+ METHOD:可以作用于方法上
+ FIELD:可以作用于成员变量上
+ * @Retention:描述注解被保留的阶段
+ * @Retention(RetentionPolicy.RUNTIME):当前被描述的注解,会保留到class字节码文件中,并被JVM读取到
+ * @Documented:描述注解是否被抽取到api文档中
+ * @Inherited:描述注解是否被子类继承
+
+
+ */
+@Target(value = {ElementType.TYPE,ElementType.METHOD,ElementType.FIELD})//value可以省略
+@Retention(RetentionPolicy.RUNTIME)//当前被描述的注解,会保留到class字节码文件中,并被JVM读取到
+@Documented
+@Inherited
+public @interface MyAnno3 {
+}
diff --git "a/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/annotation/Person.java" "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/annotation/Person.java"
new file mode 100644
index 0000000..8a422e1
--- /dev/null
+++ "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/annotation/Person.java"
@@ -0,0 +1,5 @@
+package cn.edu.Jlu.Day01.annotation;
+
+public enum Person {
+ p1,p2
+}
diff --git "a/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/annotation/Pro.java" "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/annotation/Pro.java"
new file mode 100644
index 0000000..f91b95a
--- /dev/null
+++ "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/annotation/Pro.java"
@@ -0,0 +1,13 @@
+package cn.edu.Jlu.Day01.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target(value = {ElementType.TYPE})
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Pro {
+ String className();
+ String methodName();
+}
diff --git "a/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/annotation/ReflectTest.java" "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/annotation/ReflectTest.java"
new file mode 100644
index 0000000..c91a547
--- /dev/null
+++ "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/annotation/ReflectTest.java"
@@ -0,0 +1,37 @@
+package cn.edu.Jlu.Day01.annotation;
+
+import java.lang.reflect.Method;
+
+@Pro(className = "cn.edu.Jlu.Day01.domain.Person",methodName = "eat")
+public class ReflectTest {
+ public static void main(String[] args) throws Exception {
+ //可以创建任意类的对象, 可以执行任意方法
+ /*
+ 不能改变任何类的代码。可以创建任意类的对象,可以执行任意方法
+ */
+ //1.解析注解
+ //1.1获取该类的字节码文件对象
+ Class reflectTestClass=ReflectTest.class;
+ //1.2获取注解
+ Pro pro=reflectTestClass.getAnnotation(Pro.class);
+ //1.3调用注解中象中定义的抽像方法,获取返回值
+ String className=pro.className();
+ String methodNam= pro.methodName();
+ //3.加载类近内存
+ Class cls=Class.forName(className);
+ //4.创建className对象
+ Object obj=cls.newInstance();
+ //5.获取成员方法对象】
+ Method method=cls.getMethod(methodNam);
+ method.invoke(obj);
+
+
+
+
+
+
+
+
+
+ }
+}
diff --git "a/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/annotation/Worker.java" "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/annotation/Worker.java"
new file mode 100644
index 0000000..3fb3dd1
--- /dev/null
+++ "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/annotation/Worker.java"
@@ -0,0 +1,13 @@
+package cn.edu.Jlu.Day01.annotation;
+@MyAnno(age=22,name="贾国胜",per=Person.p1,anno2=@MyAnno2,str={"贾国胜","吉林大学"})
+@MyAnno3
+public class Worker {
+ @MyAnno3
+ public String name="贾国胜";
+
+ @MyAnno3
+ public void study(){
+
+ }
+
+}
diff --git "a/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/annotation/demo/Calculator.java" "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/annotation/demo/Calculator.java"
new file mode 100644
index 0000000..2e27653
--- /dev/null
+++ "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/annotation/demo/Calculator.java"
@@ -0,0 +1,35 @@
+package cn.edu.Jlu.Day01.annotation.demo;
+
+/*
+ 定义一个计算器类
+ */
+public class Calculator {
+ //加法
+ @Check
+ public void add(){
+ String str = null;
+ str.toString();
+ System.out.println("1 + 0 =" + (1 + 0));
+ }
+ //减法
+ @Check
+ public void sub(){
+ System.out.println("1 - 0 =" + (1 - 0));
+ }
+ //乘法
+ @Check
+ public void mul(){
+ System.out.println("1 * 0 =" + (1 * 0));
+ }
+ //除法
+ @Check
+ public void div(){
+ System.out.println("1 / 0 =" + (1 / 0));
+ }
+
+
+ public void show(){
+ System.out.println("永无bug...");
+ }
+
+}
diff --git "a/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/annotation/demo/Check.java" "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/annotation/demo/Check.java"
new file mode 100644
index 0000000..c8da40b
--- /dev/null
+++ "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/annotation/demo/Check.java"
@@ -0,0 +1,12 @@
+package cn.edu.Jlu.Day01.annotation.demo;
+
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+public @interface Check {
+}
diff --git "a/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/annotation/demo/TestCheck.java" "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/annotation/demo/TestCheck.java"
new file mode 100644
index 0000000..d5d226b
--- /dev/null
+++ "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/annotation/demo/TestCheck.java"
@@ -0,0 +1,56 @@
+package cn.edu.Jlu.Day01.annotation.demo;
+
+import java.io.BufferedWriter;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.lang.reflect.Method;
+
+/*
+ 简单的测试框架
+
+ */
+public class TestCheck {
+ public static void main(String[] args) throws IOException {
+ //1.创建计算器对象
+ Calculator c = new Calculator();
+ //2.获取字节码文件对象
+ Class cls = c.getClass();
+ //3.获取所有方法
+ Method[] methods = cls.getMethods();
+
+ int number = 0;//出现异常的次数
+ BufferedWriter bw = new BufferedWriter(new FileWriter("bug.txt"));
+
+
+ for (Method method : methods) {
+ //4.判断方法上是否有Check注解
+ if(method.isAnnotationPresent(Check.class)){
+ //5.有,执行
+ try {
+ method.invoke(c);
+ } catch (Exception e) {
+ //6.捕获异常
+
+ //记录到文件中
+ number ++;
+
+ bw.write(method.getName()+ " 方法出异常了");
+ bw.newLine();
+ bw.write("异常的名称:" + e.getCause().getClass().getSimpleName());
+ bw.newLine();
+ bw.write("异常的原因:"+e.getCause().getMessage());
+ bw.newLine();
+ bw.write("--------------------------");
+ bw.newLine();
+
+ }
+ }
+ }
+
+ bw.write("本次测试一共出现 "+number+" 次异常");
+
+ bw.flush();
+ bw.close();
+ }
+
+}
diff --git "a/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/domain/Person.java" "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/domain/Person.java"
new file mode 100644
index 0000000..d0a88a0
--- /dev/null
+++ "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/domain/Person.java"
@@ -0,0 +1,45 @@
+package cn.edu.Jlu.Day01.domain;
+
+public class Person {
+ private String name;
+ private int age;
+ public String address;
+ public String number;
+ public Person(){
+
+ }
+ public Person(String name,int age){
+ this.name=name;
+ this.age=age;
+ }
+
+ @Override
+ public String toString() {
+ return "Person{" +
+ "name='" + name + '\'' +
+ ", age=" + age +
+ '}';
+ }
+ public void eat(){
+ System.out.println("我喜欢吃面条");
+ }
+ public void eat(String name,String food){
+ System.out.println(name+"喜欢吃"+food);
+ }
+
+ 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;
+ }
+}
diff --git "a/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/domain/Student.java" "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/domain/Student.java"
new file mode 100644
index 0000000..326476b
--- /dev/null
+++ "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/domain/Student.java"
@@ -0,0 +1,7 @@
+package cn.edu.Jlu.Day01.domain;
+
+public class Student {
+ public void sleep(){
+ System.out.println("sleeping....");
+ }
+}
diff --git "a/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/junit/Calculator.java" "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/junit/Calculator.java"
new file mode 100644
index 0000000..32c49c7
--- /dev/null
+++ "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/junit/Calculator.java"
@@ -0,0 +1,13 @@
+package cn.edu.Jlu.Day01.junit;
+/*
+ 计算器类
+ */
+public class Calculator {
+ public int add(int a,int b){
+ return a+b;
+ }
+ public int subtract(int a,int b){
+ return a-b;
+ }
+
+}
diff --git "a/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/junit/CalculatorTest.java" "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/junit/CalculatorTest.java"
new file mode 100644
index 0000000..15304dc
--- /dev/null
+++ "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/junit/CalculatorTest.java"
@@ -0,0 +1,9 @@
+package cn.edu.Jlu.Day01.junit;
+
+public class CalculatorTest {
+ public static void main(String[] args) {
+ Calculator ca=new Calculator();
+ System.out.println(ca.add(10,5));
+ System.out.println(ca.subtract(10,5));
+ }
+}
diff --git "a/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/reflect/ReflectDemo1.java" "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/reflect/ReflectDemo1.java"
new file mode 100644
index 0000000..bd2f8d8
--- /dev/null
+++ "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/reflect/ReflectDemo1.java"
@@ -0,0 +1,44 @@
+package cn.edu.Jlu.Day01.reflect;
+
+import cn.edu.Jlu.Day01.domain.Person;
+
+public class ReflectDemo1 {
+ /*
+ 获取Class对象的方式:
+ 1. Class.forName("全类名"):将字节码文件加载进内存,返回Class对象
+ * 多用于配置文件,将类名定义在配置文件中。读取文件,加载类
+ 2. 类名.class:通过类名的属性class获取
+ * 多用于参数的传递
+ 3. 对象.getClass():getClass()方法在Object类中定义着。
+ * 多用于对象的获取字节码的方式
+
+ * 结论:
+ 同一个字节码文件(*.class)在一次程序运行过程中,只会被加载一次,不论通过哪一种方式获取的Class对象都是同一个。
+ */
+ public static void main(String[] args) throws ClassNotFoundException {
+ //1. Class.forName("全类名"):将字节码文件加载进内存
+ Class cls1=Class.forName("cn.edu.Jlu.Day01.domain.Person");
+ System.out.println(cls1);
+ //类名.class:通过类名的属性class获取
+ Class cls2= Person.class;
+ System.out.println(cls2);
+ //3. 对象.getClass():getClass()方法在Object类中定义着。
+ Class cls3=new Person().getClass();
+ System.out.println(cls3);
+ System.out.println(cls1==cls2);
+ System.out.println(cls1==cls3);
+ /*
+ 运行结果:
+ class cn.edu.Jlu.Day01.domain.Person
+ class cn.edu.Jlu.Day01.domain.Person
+ class cn.edu.Jlu.Day01.domain.Person
+ true
+ true
+ */
+
+
+
+ }
+
+
+}
diff --git "a/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/reflect/ReflectDemo2.java" "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/reflect/ReflectDemo2.java"
new file mode 100644
index 0000000..5c09c46
--- /dev/null
+++ "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/reflect/ReflectDemo2.java"
@@ -0,0 +1,65 @@
+package cn.edu.Jlu.Day01.reflect;
+
+import cn.edu.Jlu.Day01.domain.Person;
+
+import java.lang.reflect.Field;
+import java.util.stream.Stream;
+
+public class ReflectDemo2 {
+ /*
+ Class对象功能:
+ * 获取功能:
+ 1. 获取成员变量们
+ * Field[] getFields() :获取所有public修饰的成员变量
+ * Field getField(String name) 获取指定名称的 public修饰的成员变量
+
+ * Field[] getDeclaredFields() 获取所有的成员变量,不考虑修饰符
+ * Field getDeclaredField(String name)
+ 2. 获取构造方法们
+ * Constructor>[] getConstructors()
+ * Constructor getConstructor(类>... parameterTypes)
+
+ * Constructor getDeclaredConstructor(类>... parameterTypes)
+ * Constructor>[] getDeclaredConstructors()
+ 3. 获取成员方法们:
+ * Method[] getMethods()
+ * Method getMethod(String name, 类>... parameterTypes)
+
+ * Method[] getDeclaredMethods()
+ * Method getDeclaredMethod(String name, 类>... parameterTypes)
+
+ 4. 获取全类名
+ * String getName()
+ */
+ public static void main(String[] args) throws Exception {
+ //1.过去Person的Class对象
+ Class personClass=Person.class;
+ //getFields()方法
+ Field[] fields = personClass.getFields();
+ Stream stream=Stream.of(fields);
+ stream.forEach(str-> System.out.println(str));
+ System.out.println("------------");
+
+ Field field=personClass.getField("number");
+ //
+ Person person = new Person();
+ field.set(person,"18004449293");
+ Object result=field.get(person);
+ String number=(String)result;
+ System.out.println(result);
+ System.out.println("-----------");
+
+ Field [] fields1=personClass.getDeclaredFields();
+ for (Field f:fields1
+ ) {
+ System.out.println(f);
+ }
+
+ Field f=personClass.getDeclaredField("name");
+ f.setAccessible(true);//暴力反射,不进行访问权限安全性检查
+ System.out.println(f.get(new Person()));
+
+
+
+ }
+}
diff --git "a/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/reflect/ReflectDemo3.java" "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/reflect/ReflectDemo3.java"
new file mode 100644
index 0000000..6604cf9
--- /dev/null
+++ "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/reflect/ReflectDemo3.java"
@@ -0,0 +1,34 @@
+package cn.edu.Jlu.Day01.reflect;
+
+import cn.edu.Jlu.Day01.domain.Person;
+
+import java.lang.reflect.Constructor;
+/*
+ * Field getDeclaredField(String name)
+ 2. 获取构造方法们
+ * Constructor>[] getConstructors()
+ * Constructor getConstructor(类>... parameterTypes)
+
+ * Constructor getDeclaredConstructor(类>... parameterTypes)
+ * Constructor>[] getDeclaredConstructors()
+ */
+public class ReflectDemo3 {
+ public static void main(String[] args) throws Exception {
+ //1.获取Person的Class对象
+ Class personClass= Person.class;
+ Constructor constructor=personClass.getConstructor(String.class,int.class);
+ System.out.println(constructor);
+ //newinstance()方法差创建对象
+ Object person =constructor.newInstance("张三",23);
+
+ System.out.println(person);
+
+ Constructor constructor1=personClass.getConstructor();
+ System.out.println(constructor);
+ //newinstance()方法差创建对象
+ Object person1 =constructor1.newInstance();
+
+ System.out.println(person1);
+ System.out.println(personClass.newInstance());
+ }
+}
diff --git "a/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/reflect/ReflectDemo4.java" "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/reflect/ReflectDemo4.java"
new file mode 100644
index 0000000..e182c2c
--- /dev/null
+++ "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/reflect/ReflectDemo4.java"
@@ -0,0 +1,44 @@
+package cn.edu.Jlu.Day01.reflect;
+
+import cn.edu.Jlu.Day01.domain.Person;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+public class ReflectDemo4 {
+ /*
+ 3. 获取成员方法们:
+ * Method[] getMethods()
+ * Method getMethod(String name, 类>... parameterTypes)
+
+ * Method[] getDeclaredMethods()
+ * Method getDeclaredMethod(String name, 类>... parameterTypes)
+ */
+ public static void main(String[] args) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
+ Class personClass= Person.class;
+ //获取指定名称的方法
+ Method method1=personClass.getMethod("eat");
+ //执行方法
+ method1.invoke(new Person());
+
+ Method method2=personClass.getMethod("eat",String.class,String.class);
+ method2.invoke(new Person(),"贾国胜","火锅");
+ //打印所方法
+ Method [] methods=personClass.getMethods();
+ for (Method method:methods
+ ) {
+ System.out.print(method+"-");
+ System.out.println(method.getName());
+
+ }
+
+ String className=personClass.getName();
+ System.out.println(className);
+
+
+
+
+
+
+ }
+}
diff --git "a/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/reflect/ReflectTest.java" "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/reflect/ReflectTest.java"
new file mode 100644
index 0000000..0f0605f
--- /dev/null
+++ "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/reflect/ReflectTest.java"
@@ -0,0 +1,39 @@
+package cn.edu.Jlu.Day01.reflect;
+
+import java.io.InputStream;
+import java.lang.reflect.Method;
+import java.util.Properties;
+
+public class ReflectTest {
+ public static void main(String[] args) throws Exception {
+ //可以创建任意类的对象, 可以执行任意方法
+ /*
+ 不能改变任何类的代码。可以创建任意类的对象,可以执行任意方法
+ */
+
+ //2.创建Properties对象
+ Properties pro=new Properties();
+ //2.加载配置文件
+ //获取class目录下的配置文件
+ ClassLoader classLoader=ReflectTest.class.getClassLoader();
+ InputStream is=classLoader.getResourceAsStream("pro.properties");
+ pro.load(is);
+ //3获取配置文件中的定义的数据
+ String className=pro.getProperty("className");
+
+ String methodName=pro.getProperty("methodName");
+ // 4.加载类进内存
+ Class cls=Class.forName(className);
+ //5.获取类的对象
+ Object obj=cls.newInstance();
+ //6.获取对象
+ Method method=cls.getMethod(methodName);
+ //7.执行方法
+ method.invoke(obj);
+
+
+
+
+
+ }
+}
diff --git "a/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/test/CalculatorTest.java" "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/test/CalculatorTest.java"
new file mode 100644
index 0000000..16135e0
--- /dev/null
+++ "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day01/test/CalculatorTest.java"
@@ -0,0 +1,43 @@
+package cn.edu.Jlu.Day01.test;
+
+import cn.edu.Jlu.Day01.junit.Calculator;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class CalculatorTest {
+ /*
+ 初始化方法,用于申请资源
+ 所测试方法在执行前都会执行这个方法
+ */
+ @Before
+ public void init(){
+ System.out.println("init...");
+ }
+ /*
+ 释放资源方法,在所有测试方法执行完毕后,都会自动执行这个方法
+ */
+ @After
+ public void close(){
+ System.out.println("close...");
+ }
+ /*
+ 测试add()方法
+ */
+ @Test
+ public void testAdd(){
+ //int i=3/0;
+ Calculator c=new Calculator();
+ int result=c.add(10,5);
+ System.out.println(result);
+ Assert.assertEquals(15,result);
+ }
+ @Test
+ public void testSubTract(){
+ Calculator c=new Calculator();
+ int result=c.subtract(10,5);
+ System.out.println(result);
+ Assert.assertEquals(5,result);
+ }
+}
diff --git "a/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day03JDBC/domain/Emp.java" "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day03JDBC/domain/Emp.java"
new file mode 100644
index 0000000..e43a59e
--- /dev/null
+++ "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day03JDBC/domain/Emp.java"
@@ -0,0 +1,93 @@
+package cn.edu.Jlu.Day03JDBC.domain;
+
+import java.util.Date;
+
+public class Emp {
+
+ private int id; //员工编号
+ private String ename; //员工姓名
+ private int job_id; //职务编号
+ private int mgr; //直接上级编号
+ private Date joinDate; // 入职日期
+ private double salary; //工资
+ private double bonus; //分红
+ private int dept_id;//部门编号
+
+ @Override
+ public String toString() {
+ return "Emp{" +
+ "id=" + id +
+ ", ename='" + ename + '\'' +
+ ", job_id=" + job_id +
+ ", mgr=" + mgr +
+ ", joinDate=" + joinDate +
+ ", salary=" + salary +
+ ", bonus=" + bonus +
+ ", dept_id=" + dept_id +
+ '}';
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getEname() {
+ return ename;
+ }
+
+ public void setEname(String ename) {
+ this.ename = ename;
+ }
+
+ public int getJob_id() {
+ return job_id;
+ }
+
+ public void setJob_id(int job_id) {
+ this.job_id = job_id;
+ }
+
+ public int getMgr() {
+ return mgr;
+ }
+
+ public void setMgr(int mgr) {
+ this.mgr = mgr;
+ }
+
+ public Date getJoinDate() {
+ return joinDate;
+ }
+
+ public void setJoinDate(Date joinDate) {
+ this.joinDate = joinDate;
+ }
+
+ public double getSalary() {
+ return salary;
+ }
+
+ public void setSalary(double salary) {
+ this.salary = salary;
+ }
+
+ public double getBonus() {
+ return bonus;
+ }
+
+ public void setBonus(double bonus) {
+ this.bonus = bonus;
+ }
+
+ public int getDept_id() {
+ return dept_id;
+ }
+
+ public void setDept_id(int dept_id) {
+ this.dept_id = dept_id;
+ }
+}
diff --git "a/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day03JDBC/jdbc/JDBCDemo01.java" "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day03JDBC/jdbc/JDBCDemo01.java"
new file mode 100644
index 0000000..ac851da
--- /dev/null
+++ "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day03JDBC/jdbc/JDBCDemo01.java"
@@ -0,0 +1,39 @@
+package cn.edu.Jlu.Day03JDBC.jdbc;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.Statement;
+
+public class JDBCDemo01 {
+ public static void main(String[] args) throws Exception{
+ //1.导入jar包
+ //2.注册驱动
+ Class.forName("com.mysql.jdbc.Driver");
+ //获取连接对象
+
+ Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/db3","root","jiags1997");
+
+ //4 定义sql语句
+ String sql="update account set balance=500 where id =1;";
+
+ //5 获取执行sql语句的对象
+ Statement stmt=con.createStatement();
+ //6 执行sql
+ int count=stmt.executeUpdate(sql);
+ //7处理结果
+ System.out.println(count);
+ //8 释放资源
+ stmt.close();
+ con.close();
+
+
+
+
+
+
+
+
+ }
+}
+
+
diff --git "a/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day03JDBC/jdbc/JDBCDemo02.java" "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day03JDBC/jdbc/JDBCDemo02.java"
new file mode 100644
index 0000000..087511b
--- /dev/null
+++ "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day03JDBC/jdbc/JDBCDemo02.java"
@@ -0,0 +1,52 @@
+package cn.edu.Jlu.Day03JDBC.jdbc;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+public class JDBCDemo02 {
+ public static void main(String[] args) {
+ Statement stmt = null;
+ Connection conn = null;
+ //1.注册驱动
+ try{
+ Class.forName("com.mysql.jdbc.Driver");
+ //2.连接数据库
+ conn= DriverManager.getConnection("jdbc:mysql://localhost:3306/db3","root","jiags1997");
+ //3.返回执行sql对想法
+ stmt= conn.createStatement();
+ //4.定义sql语句
+ String sql="insert into account (id,name,balance) values(3,'王五',2000)";
+
+ //5执行语句sql
+ int count=stmt.executeUpdate(sql);
+ System.out.println(count);
+ if(count>0)
+ System.out.println("执行成功!");
+ else
+ System.out.println("执行失败!");
+ }catch(ClassNotFoundException e){
+ e.printStackTrace();
+ }catch (SQLException e){
+ e.getErrorCode();
+ }finally {
+ if(stmt!=null){
+ try{
+ stmt.close();
+ }catch (SQLException e){
+ System.out.println(e);
+ }
+
+ }
+ if(conn!=null){
+ try{
+ conn.close();
+
+ }catch (SQLException e){
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+}
diff --git "a/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day03JDBC/jdbc/JDBCDemo03.java" "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day03JDBC/jdbc/JDBCDemo03.java"
new file mode 100644
index 0000000..f5f2439
--- /dev/null
+++ "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day03JDBC/jdbc/JDBCDemo03.java"
@@ -0,0 +1,61 @@
+package cn.edu.Jlu.Day03JDBC.jdbc;
+
+import java.sql.*;
+
+public class JDBCDemo03 {
+ public static void main(String[] args) {
+ Statement stmt = null;
+ Connection conn = null;
+ ResultSet rs = null;
+ //1.注册驱动
+ try {
+ Class.forName("com.mysql.jdbc.Driver");
+ //2.连接数据库
+ conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/db3", "root", "jiags1997");
+ //3.返回执行sql对想法
+ stmt = conn.createStatement();
+ //4.定义sql语句
+ String sql = "select *from account";
+
+ //5执行语句sql
+ rs = stmt.executeQuery(sql);
+ while (rs.next()) {//循环判断游标是否是最后一行
+ int id = rs.getInt(1);
+ String name = rs.getString(2);
+ double balbance = rs.getDouble(3);
+ System.out.println(id+"..."+name+"..."+balbance);
+
+ }
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace();
+ } catch (SQLException e) {
+ e.getErrorCode();
+ } finally {
+ if (rs != null) {
+ try {
+ rs.close();
+ } catch (SQLException e) {
+ System.out.println(e);
+ }
+
+
+ if (stmt != null) {
+ try {
+ stmt.close();
+ } catch (SQLException e) {
+ System.out.println(e);
+ }
+
+ }
+ if (conn != null) {
+ try {
+ conn.close();
+
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+ }
+}
diff --git "a/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day03JDBC/jdbc/JDBCDemo04.java" "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day03JDBC/jdbc/JDBCDemo04.java"
new file mode 100644
index 0000000..0706196
--- /dev/null
+++ "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day03JDBC/jdbc/JDBCDemo04.java"
@@ -0,0 +1,8 @@
+package cn.edu.Jlu.Day03JDBC.jdbc;
+
+public class JDBCDemo04 {
+
+ public static void main(String[] args) {
+
+ }
+}
diff --git "a/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day03JDBC/jdbc/JDBCDemo06.java" "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day03JDBC/jdbc/JDBCDemo06.java"
new file mode 100644
index 0000000..780d3a2
--- /dev/null
+++ "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day03JDBC/jdbc/JDBCDemo06.java"
@@ -0,0 +1,68 @@
+package cn.edu.Jlu.Day03JDBC.jdbc;
+
+import cn.edu.Jlu.Day03JDBC.domain.Emp;
+import cn.edu.Jlu.Day03JDBC.util.JDBCUtils;
+
+import java.sql.*;
+import java.util.ArrayList;
+import java.util.List;
+
+public class JDBCDemo06 {
+ public static void main(String[] args) {
+ List list=new JDBCDemo06().findAll();
+ System.out.println(list);
+ }
+ public List findAll(){
+
+ Connection conn=null;
+ Statement stmt=null;
+ ResultSet rs=null;
+ List list=new ArrayList();
+ try{
+ //1.注册驱动
+
+ //2.连接数据库
+ conn= JDBCUtils.getConnection();
+
+ //3.获取操作sql的statement对象
+ stmt=conn.createStatement();
+ //4.定义sql语句
+ String sql="select * from emp";
+ //5.执行sql语句
+ rs=stmt.executeQuery(sql);
+ //6.遍历结果集,封装对象,装载集合
+
+ while(rs.next()){
+ //获取数据
+ int id=rs.getInt("id");
+ String ename = rs.getString("ename");
+ int job_id = rs.getInt("job_id");
+ int mgr = rs.getInt("mgr");
+ Date joindate = rs.getDate("joindate");
+ double salary = rs.getDouble("salary");
+ double bonus = rs.getDouble("bonus");
+ int dept_id = rs.getInt("dept_id");
+ //创建对象
+ Emp emp=new Emp();
+ emp.setId(id);
+ emp.setEname(ename);
+ emp.setJob_id(job_id);
+ emp.setMgr(mgr);
+ emp.setJoinDate(joindate);
+ emp.setSalary(salary);
+ emp.setBonus(bonus);
+ emp.setDept_id(dept_id);
+ list.add(emp);
+ }
+
+ }
+ catch (SQLException e){
+ e.printStackTrace();
+ }
+ finally {
+ JDBCUtils.close(rs,stmt,conn);
+
+ }
+ return list;
+ }
+}
diff --git "a/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day03JDBC/jdbc/JDBCDemo5.java" "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day03JDBC/jdbc/JDBCDemo5.java"
new file mode 100644
index 0000000..1c39061
--- /dev/null
+++ "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day03JDBC/jdbc/JDBCDemo5.java"
@@ -0,0 +1,94 @@
+package cn.edu.Jlu.Day03JDBC.jdbc;
+
+import cn.edu.Jlu.Day03JDBC.domain.Emp;
+
+import java.sql.*;
+import java.util.ArrayList;
+import java.util.List;
+
+public class JDBCDemo5 {
+ /**
+ * 查询所有的emp对象
+ * @return
+ */
+ public static void main(String[] args) {
+ List list=new JDBCDemo5().findAll();
+ System.out.println(list);
+ }
+ public List findAll(){
+
+ Connection conn=null;
+ Statement stmt=null;
+ ResultSet rs=null;
+ List list=new ArrayList();
+ try{
+ //1.注册驱动
+ Class.forName("com.mysql.jdbc.Driver");
+ //2.连接数据库
+ conn= DriverManager.getConnection("jdbc:mysql://localhost:3306/db3", "root", "jiags1997");
+
+ //3.获取操作sql的statement对象
+ stmt=conn.createStatement();
+ //4.定义sql语句
+ String sql="select * from emp";
+ //5.执行sql语句
+ rs=stmt.executeQuery(sql);
+ //6.遍历结果集,封装对象,装载集合
+
+ while(rs.next()){
+ //获取数据
+ int id=rs.getInt("id");
+ String ename = rs.getString("ename");
+ int job_id = rs.getInt("job_id");
+ int mgr = rs.getInt("mgr");
+ Date joindate = rs.getDate("joindate");
+ double salary = rs.getDouble("salary");
+ double bonus = rs.getDouble("bonus");
+ int dept_id = rs.getInt("dept_id");
+ //创建对象
+ Emp emp=new Emp();
+ emp.setId(id);
+ emp.setEname(ename);
+ emp.setJob_id(job_id);
+ emp.setMgr(mgr);
+ emp.setJoinDate(joindate);
+ emp.setSalary(salary);
+ emp.setBonus(bonus);
+ emp.setDept_id(dept_id);
+ list.add(emp);
+ }
+
+ }catch (ClassNotFoundException e){
+ e.printStackTrace();
+ }
+ catch (SQLException e){
+ e.printStackTrace();
+ }
+ finally {
+ try{
+ if(rs!=null)
+ rs.close();
+ }catch (SQLException e){
+ e.printStackTrace();
+ }
+ try{
+ if(stmt!=null){
+ stmt.close();
+ }
+ }catch (SQLException e){
+ e.printStackTrace();
+ }
+ try{
+ if(conn!=null){
+ conn.close();
+
+ }
+ }catch (SQLException e){
+ e.printStackTrace();
+ }
+
+ }
+ return list;
+ }
+}
+
diff --git "a/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day03JDBC/util/JDBCUtils.java" "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day03JDBC/util/JDBCUtils.java"
new file mode 100644
index 0000000..b5792bd
--- /dev/null
+++ "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day03JDBC/util/JDBCUtils.java"
@@ -0,0 +1,105 @@
+package cn.edu.Jlu.Day03JDBC.util;
+
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.sql.*;
+import java.util.Properties;
+
+/*
+ jdbc工具类
+ */
+public class JDBCUtils {
+ private static String url;
+ private static String user;
+ private static String password;
+ private static String driver;
+ static{
+ Properties pro=new Properties();
+ try {
+ //获取class目录下的配置文件
+ ClassLoader classLoader= JDBCUtils.class.getClassLoader();
+ InputStream is=classLoader.getResourceAsStream("jdbc.properties");
+ //URL res=classLoader.getResource("jdbc.properties");
+ //String path=res.getPath();
+ // pro.load(new FileReader(path));
+
+ pro.load(is);//将文件加载到内存
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ url=pro.getProperty("url");
+ user=pro.getProperty("user");
+ password=pro.getProperty("password");
+ driver=pro.getProperty("driver");
+ // 注册驱动
+ try {
+ Class.forName(driver);
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace();
+ }
+ }
+ /**
+ * 获取连接的方法
+ * @return
+ */
+ public static Connection getConnection() throws SQLException {
+
+ return DriverManager.getConnection(url,user,password);
+
+ }
+
+ /**
+ * 释放资源方法
+ * @param stmt
+ * @param conn
+ */
+ public static void close(Statement stmt,Connection conn){
+ if(stmt!=null){
+ try {
+ stmt.close();
+ } catch (SQLException throwables) {
+ throwables.printStackTrace();
+ }
+ }
+ if(conn!=null){
+ try {
+ conn.close();
+ } catch (SQLException throwables) {
+ throwables.printStackTrace();
+ }
+ }
+ }
+
+ /**
+ * 释放资源方法
+ * @param rs
+ * @param stmt
+ * @param conn
+ */
+ public static void close(ResultSet rs,Statement stmt, Connection conn){
+ if(rs!=null){
+ try {
+ rs.close();
+ } catch (SQLException throwables) {
+ throwables.printStackTrace();
+ }
+ }
+
+ if(stmt!=null){
+ try {
+ stmt.close();
+ } catch (SQLException throwables) {
+ throwables.printStackTrace();
+ }
+ }
+ if(conn!=null){
+ try {
+ conn.close();
+ } catch (SQLException throwables) {
+ throwables.printStackTrace();
+ }
+ }
+ }
+
+}
diff --git "a/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day04JDBCDataSource/DruidDemo/RruidUtilsDemo.java" "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day04JDBCDataSource/DruidDemo/RruidUtilsDemo.java"
new file mode 100644
index 0000000..6dc4447
--- /dev/null
+++ "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day04JDBCDataSource/DruidDemo/RruidUtilsDemo.java"
@@ -0,0 +1,33 @@
+package cn.edu.Jlu.Day04JDBCDataSource.DruidDemo;
+
+import cn.edu.Jlu.Day04JDBCDataSource.Utils.JDBCUtils;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+
+public class RruidUtilsDemo {
+ public static void main(String[] args) {
+ //完成添加操作
+ Connection conn=null;
+ PreparedStatement pstmt=null;
+
+
+ try {
+ //1.获取连接
+ conn=JDBCUtils.getConnection();
+ //2.定义sql
+ String sql="insert into account values(null,?,?)";
+ //3获取PreparedStatent 对象
+ pstmt=conn.prepareStatement(sql);
+ pstmt.setString(1,"naruto");
+ pstmt.setDouble(2,2000);
+ int count=pstmt.executeUpdate();
+ System.out.println(count);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }finally {
+ JDBCUtils.close(pstmt,conn);
+ }
+
+ }
+}
diff --git "a/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day04JDBCDataSource/JDBCTemplate/JDBCTemplateDemo2.java" "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day04JDBCDataSource/JDBCTemplate/JDBCTemplateDemo2.java"
new file mode 100644
index 0000000..ff51e67
--- /dev/null
+++ "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day04JDBCDataSource/JDBCTemplate/JDBCTemplateDemo2.java"
@@ -0,0 +1,134 @@
+package cn.edu.Jlu.Day04JDBCDataSource.JDBCTemplate;
+
+
+import cn.edu.Jlu.Day04JDBCDataSource.Utils.JDBCUtils;
+import cn.edu.Jlu.Day04JDBCDataSource.domain.Emp;
+import org.junit.jupiter.api.Test;
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.jdbc.core.RowMapper;
+
+import java.sql.Date;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.List;
+import java.util.Map;
+
+public class JDBCTemplateDemo2 {
+
+ //单元测试,可以让方法独立执行
+ private JdbcTemplate jt=new JdbcTemplate(JDBCUtils.getDataSource());
+
+ /**
+ * 修改一号数据的的salary为10000
+ */
+ @Test
+ public void test1(){
+ //1.获取JDBCTemolate对象
+
+ //2.定义sql
+ String sql="update emp set salary=10000 where id=1001";
+ int count=jt.update(sql);
+ System.out.println(count);
+
+ }
+
+ /**
+ * 添加一条数据
+ */
+ @Test
+ public void test2(){
+ String sql="insert into emp(id,ename,dept_id) values(?,?,?)";
+ int count=jt.update(sql,1015,"郭靖",10);//防止sql注入
+ System.out.println(count);
+ }
+
+ /**
+ * 删除刚才添加的记录
+ */
+ @Test
+ public void test3(){
+ String sql="delete from emp where id=?";
+ int count=jt.update(sql,1015);
+ System.out.println(count);
+ }
+
+ /**
+ * 查询emp表中的记录封装为map
+ * 注意:这个方法的查询结果集长度只能是1
+ */
+ @Test
+ public void test4(){
+ String sql="select * from emp where id=?";
+ Map map=jt.queryForMap(sql,1001);
+ //{id=1001, ename=孙悟空, job_id=4, mgr=1004, joindate=2000年12月17日, salary=10000.00, bonus=null, dept_id=20}
+ System.out.println(map);
+ }
+
+ /**
+ * 查询emp表所有内容,封装成List集合
+ */
+ @Test
+ public void test5(){
+ String sql="select * from emp";
+ List> maps = jt.queryForList(sql);
+ maps.stream().forEach((map)-> System.out.println(map));
+ }
+
+ /**
+ * 查询所有记录,将其封装为Emp对象的List集合
+ */
+ @Test
+ public void test6(){
+ String sql="select * from emp";
+ List list=jt.query(sql, new RowMapper() {
+ @Override
+ public Emp mapRow(ResultSet resultSet, int i) throws SQLException {
+
+ Emp emp = new Emp();
+ Integer id=resultSet.getInt("id");
+ String ename = resultSet.getString("ename");
+ Integer job_id = resultSet.getInt("job_id");
+ Integer mgr = resultSet.getInt("mgr");
+ Date joinDate = resultSet.getDate("joinDate");
+ Double salary = resultSet.getDouble("salary");
+ Double bonus = resultSet.getDouble("bonus");
+ Integer dept_id = resultSet.getInt("dept_id");
+ emp.setId(id);
+ emp.setEname(ename);
+ emp.setJob_id(job_id);
+ emp.setMgr(mgr);
+ emp.setJoinDate(joinDate);
+ emp.setSalary(salary);
+ emp.setBonus(bonus);
+ emp.setDept_id(dept_id);
+
+ return emp;
+ }
+ });
+
+ list.stream().forEach(emp-> System.out.println(emp));
+
+ }
+
+ /**
+ * 使用Spring框架提供好的接口实现步骤六
+ */
+ @Test
+ public void test7(){
+ String sql="select * from emp";
+ Listlist=jt.query(sql,new BeanPropertyRowMapper(Emp.class));
+
+ list.stream().forEach(emp -> System.out.println(emp));
+ }
+
+ /**
+ * 查询emp表中记录数量
+ */
+ @Test
+ public void test8(){
+ String sql="select count(id) from emp";
+ Long total=jt.queryForObject(sql,Long.class);
+ System.out.println(total);
+ }
+}
diff --git "a/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day04JDBCDataSource/Utils/JDBCUtils.java" "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day04JDBCDataSource/Utils/JDBCUtils.java"
new file mode 100644
index 0000000..97b0146
--- /dev/null
+++ "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day04JDBCDataSource/Utils/JDBCUtils.java"
@@ -0,0 +1,108 @@
+package cn.edu.Jlu.Day04JDBCDataSource.Utils;
+
+import com.alibaba.druid.pool.DruidDataSourceFactory;
+
+import javax.sql.DataSource;
+import java.io.IOException;
+import java.io.InputStream;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.Properties;
+
+/**
+ * 连接池的工具类
+ */
+public class JDBCUtils {
+ private static DataSource ds;
+ static{
+ try {
+ Properties pro=new Properties();
+ ClassLoader classLoader=JDBCUtils.class.getClassLoader();
+ InputStream is=classLoader.getResourceAsStream("druid.properties");
+ pro.load(is);
+ ds= DruidDataSourceFactory.createDataSource(pro);
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * 获取连接方法
+ * @return
+ * @throws Exception
+ */
+ public static Connection getConnection() throws Exception {
+ return ds.getConnection();
+ }
+
+ /**
+ * 释放资源方法
+ * @param stmt
+ * @param conn
+ */
+ public static void close(Statement stmt,Connection conn ){
+ try {
+ if(stmt!=null){
+ stmt.close();
+ }
+
+ } catch (SQLException throwables) {
+ throwables.printStackTrace();
+ }
+ try {
+ if(conn!=null){
+ conn.close();
+ }
+
+ } catch (SQLException throwables) {
+ throwables.printStackTrace();
+ }
+
+ }
+
+ /**
+ * 释放资源方法
+ * @param rs
+ * @param stmt
+ * @param conn
+ */
+ public static void close(ResultSet rs,Statement stmt, Connection conn ){
+ try {
+ if(rs!=null){
+ rs.close();
+ }
+
+ } catch (SQLException throwables) {
+ throwables.printStackTrace();
+ }
+ try {
+ if(stmt!=null){
+ stmt.close();
+ }
+
+ } catch (SQLException throwables) {
+ throwables.printStackTrace();
+ }
+ try {
+ if(conn!=null){
+ conn.close();
+ }
+
+ } catch (SQLException throwables) {
+ throwables.printStackTrace();
+ }
+
+ }
+
+ /**
+ * 获取连接池方法
+ * @return
+ */
+ public static DataSource getDataSource(){
+ return ds;
+ }
+}
diff --git "a/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day04JDBCDataSource/cp30/C3p0Demo.java" "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day04JDBCDataSource/cp30/C3p0Demo.java"
new file mode 100644
index 0000000..479bcf5
--- /dev/null
+++ "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day04JDBCDataSource/cp30/C3p0Demo.java"
@@ -0,0 +1,25 @@
+package cn.edu.Jlu.Day04JDBCDataSource.cp30;
+
+import com.mchange.v2.c3p0.ComboPooledDataSource;
+
+import javax.sql.DataSource;
+import java.sql.Connection;
+import java.sql.SQLException;
+
+/**
+ * c3p0介绍演示
+ *
+ */
+public class C3p0Demo {
+ public static void main(String[] args) throws SQLException {
+ //创建数据库连接池对象
+ DataSource ds=new ComboPooledDataSource();
+ //2.获取连接对象
+ Connection conn=ds.getConnection();
+ //3.打印
+ System.out.println(conn);
+ conn.close();
+
+
+ }
+}
diff --git "a/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day04JDBCDataSource/cp30/C3p0Demo2.java" "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day04JDBCDataSource/cp30/C3p0Demo2.java"
new file mode 100644
index 0000000..73bc8bd
--- /dev/null
+++ "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day04JDBCDataSource/cp30/C3p0Demo2.java"
@@ -0,0 +1,28 @@
+package cn.edu.Jlu.Day04JDBCDataSource.cp30;
+
+import com.mchange.v2.c3p0.ComboPooledDataSource;
+
+import javax.sql.DataSource;
+import java.sql.Connection;
+import java.sql.SQLException;
+
+/**
+ * 连接池参数的验证
+ */
+public class C3p0Demo2 {
+ public static void main(String[] args) throws SQLException {
+
+ DataSource ds=new ComboPooledDataSource();
+ for (int i = 0; i < 11; i++) { + Connection conn=ds.getConnection(); + System.out.println(i+":"+conn); + if(i==5){ + conn.close(); + } + + } + + + + } + } diff --git "a/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day04JDBCDataSource/cp30/C3p0Demo3.java" "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day04JDBCDataSource/cp30/C3p0Demo3.java" new file mode 100644 index 0000000..9016ccb --- /dev/null +++ "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day04JDBCDataSource/cp30/C3p0Demo3.java" @@ -0,0 +1,19 @@ +package cn.edu.Jlu.Day04JDBCDataSource.cp30; + +import com.mchange.v2.c3p0.ComboPooledDataSource; + +import javax.sql.DataSource; +import java.sql.Connection; +import java.sql.SQLException; + +public class C3p0Demo3 { + public static void main(String[] args) throws SQLException { + DataSource ds=new ComboPooledDataSource("otherc3p0"); + for (int i = 0; i < 8; i++) { + Connection conn=ds.getConnection(); + System.out.println(i+":"+conn); + + } + + } +} diff --git "a/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day04JDBCDataSource/domain/Emp.java" "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day04JDBCDataSource/domain/Emp.java" new file mode 100644 index 0000000..5077981 --- /dev/null +++ "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day04JDBCDataSource/domain/Emp.java" @@ -0,0 +1,92 @@ +package cn.edu.Jlu.Day04JDBCDataSource.domain; + +import java.util.Date; + +public class Emp { + private Integer id; //员工编号 + private String ename; //员工姓名 + private Integer job_id; //职务编号 + private Integer mgr; //直接上级编号 + private Date joinDate; // 入职日期 + private Double salary; //工资 + private Double bonus; //分红 + private Integer dept_id;//部门编号 + + @Override + public String toString() { + return "Emp{" + + "id=" + id + + ", ename='" + ename + '\'' + + ", job_id=" + job_id + + ", mgr=" + mgr + + ", joinDate=" + joinDate + + ", salary=" + salary + + ", bonus=" + bonus + + ", dept_id=" + dept_id + + '}'; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getEname() { + return ename; + } + + public void setEname(String ename) { + this.ename = ename; + } + + public Integer getJob_id() { + return job_id; + } + + public void setJob_id(Integer job_id) { + this.job_id = job_id; + } + + public Integer getMgr() { + return mgr; + } + + public void setMgr(Integer mgr) { + this.mgr = mgr; + } + + public Date getJoinDate() { + return joinDate; + } + + public void setJoinDate(Date joinDate) { + this.joinDate = joinDate; + } + + public Double getSalary() { + return salary; + } + + public void setSalary(Double salary) { + this.salary = salary; + } + + public Double getBonus() { + return bonus; + } + + public void setBonus(Double bonus) { + this.bonus = bonus; + } + + public Integer getDept_id() { + return dept_id; + } + + public void setDept_id(Integer dept_id) { + this.dept_id = dept_id; + } +} diff --git "a/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day04JDBCDataSource/druid/DruidDemo.java" "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day04JDBCDataSource/druid/DruidDemo.java" new file mode 100644 index 0000000..921053c --- /dev/null +++ "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/cn/edu/Jlu/Day04JDBCDataSource/druid/DruidDemo.java" @@ -0,0 +1,31 @@ +package cn.edu.Jlu.Day04JDBCDataSource.druid; + +import com.alibaba.druid.pool.DruidDataSourceFactory; + +import javax.sql.DataSource; +import java.io.InputStream; +import java.sql.Connection; +import java.util.Properties; + +/** + * Druid演示 + */ +public class DruidDemo { + public static void main(String[] args) throws Exception { + //1.导入jar包 + //2.定义配置文件 + //3.加载配置文件 + Properties pro=new Properties(); + ClassLoader classLoader=DruidDemo.class.getClassLoader(); + InputStream is=classLoader.getResourceAsStream("druid.properties"); + + pro.load(is); + //4.获取连接池对象 + DataSource ds=DruidDataSourceFactory.createDataSource(pro); + //5.获取连接 + Connection conn=ds.getConnection(); + System.out.println(conn); + + } +} + diff --git "a/350円277円233円351円230円266円350円257円255円346円263円225円/src/druid.properties" "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/druid.properties" new file mode 100644 index 0000000..913a566 --- /dev/null +++ "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/druid.properties" @@ -0,0 +1,7 @@ +driverClassName=com.mysql.jdbc.Driver +url=jdbc:mysql://127.0.0.1:3306/db3?useUnicode=true&characterEncoding=utf8 +username=root +password=jiags1997 +initialSize=5 +maxActive=10 +maxWait=3000 \ No newline at end of file diff --git "a/350円277円233円351円230円266円350円257円255円346円263円225円/src/jdbc.properties" "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/jdbc.properties" new file mode 100644 index 0000000..da6e5ae --- /dev/null +++ "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/jdbc.properties" @@ -0,0 +1,4 @@ +url=jdbc:mysql://localhost:3306/db3 +user=root +password=jiags1997 +driver=com.mysql.jdbc.Driver \ No newline at end of file diff --git "a/350円277円233円351円230円266円350円257円255円346円263円225円/src/pro.properties" "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/pro.properties" new file mode 100644 index 0000000..b5501c7 --- /dev/null +++ "b/350円277円233円351円230円266円350円257円255円346円263円225円/src/pro.properties" @@ -0,0 +1,2 @@ +className=cn.edu.Jlu.Day01.domain.Person +methodName=eat diff --git "a/350円277円233円351円230円266円350円257円255円346円263円225円/351円253円230円347円272円247円350円257円255円346円263円225円.iml" "b/350円277円233円351円230円266円350円257円255円346円263円225円/351円253円230円347円272円247円350円257円255円346円263円225円.iml" new file mode 100644 index 0000000..9dbccb7 --- /dev/null +++ "b/350円277円233円351円230円266円350円257円255円346円263円225円/351円253円230円347円272円247円350円257円255円346円263円225円.iml" @@ -0,0 +1,42 @@ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file