xerga 2 жил өмнө
parent
commit
3dc8de541e
67 өөрчлөгдсөн 2244 нэмэгдсэн , 0 устгасан
  1. 3 0
      JavaSE/.idea/modules.xml
  2. 21 0
      JavaSE/day17/day17.iml
  3. 281 0
      JavaSE/day17/src/com/lovecoding/day17/api/TestString.java
  4. 77 0
      JavaSE/day17/src/com/lovecoding/day17/api/TestStringBuffer.java
  5. 57 0
      JavaSE/day17/src/com/lovecoding/day17/ex01/Test01.java
  6. 159 0
      JavaSE/day17/src/com/lovecoding/day17/ex01/Test02.java
  7. 60 0
      JavaSE/day17/src/com/lovecoding/day17/ex01/Test03.java
  8. 21 0
      JavaSE/day18/day18.iml
  9. 63 0
      JavaSE/day18/src/com/lovecoding/day18/MyArray.java
  10. 214 0
      JavaSE/day18/src/com/lovecoding/day18/coll01/TestCollection01.java
  11. 50 0
      JavaSE/day18/src/com/lovecoding/day18/ex01/Student.java
  12. 79 0
      JavaSE/day18/src/com/lovecoding/day18/ex01/TestStudent.java
  13. 62 0
      JavaSE/day18/src/com/lovecoding/day18/ex02/Employee.java
  14. 12 0
      JavaSE/day18/src/com/lovecoding/day18/ex02/EmployeeAgeComparator.java
  15. 38 0
      JavaSE/day18/src/com/lovecoding/day18/ex02/TestEmployee.java
  16. 39 0
      JavaSE/day18/src/com/lovecoding/day18/ex03/Coordinate.java
  17. 18 0
      JavaSE/day18/src/com/lovecoding/day18/ex03/TestCoordinate.java
  18. 50 0
      JavaSE/day18/src/com/lovecoding/day18/fanxing01/Student.java
  19. 72 0
      JavaSE/day18/src/com/lovecoding/day18/fanxing01/TestFanXing.java
  20. 31 0
      JavaSE/day18/src/com/lovecoding/day18/iterator01/TestIterator.java
  21. 74 0
      JavaSE/day18/src/com/lovecoding/day18/iterator01/TestIterator2.java
  22. 21 0
      JavaSE/day19/day19.iml
  23. 97 0
      JavaSE/day19/src/com/lovecoding/day19/ex01/Test01.java
  24. 63 0
      JavaSE/day19/src/com/lovecoding/day19/ex02/TestStudent.java
  25. 68 0
      JavaSE/day19/src/com/lovecoding/day19/list01/TestLinkedList.java
  26. 120 0
      JavaSE/day19/src/com/lovecoding/day19/list01/TestList.java
  27. 46 0
      JavaSE/day19/src/com/lovecoding/day19/list01/TestListIterator.java
  28. 24 0
      JavaSE/day19/src/com/lovecoding/day19/list01/TestStack.java
  29. 25 0
      JavaSE/day19/src/com/lovecoding/day19/list01/TestVector.java
  30. 128 0
      JavaSE/day19/src/com/lovecoding/day19/map01/TestMap01.java
  31. 41 0
      JavaSE/day19/src/com/lovecoding/day19/set01/Person.java
  32. 22 0
      JavaSE/day19/src/com/lovecoding/day19/set01/TestLinkedHashSet.java
  33. 24 0
      JavaSE/day19/src/com/lovecoding/day19/set01/TestSet.java
  34. 84 0
      JavaSE/day19/src/com/lovecoding/day19/set01/TestTreeSet.java
  35. BIN
      JavaSE/out/production/day17/com/lovecoding/day17/api/TestString.class
  36. BIN
      JavaSE/out/production/day17/com/lovecoding/day17/api/TestStringBuffer.class
  37. BIN
      JavaSE/out/production/day17/com/lovecoding/day17/ex01/Test01.class
  38. BIN
      JavaSE/out/production/day17/com/lovecoding/day17/ex01/Test02.class
  39. BIN
      JavaSE/out/production/day17/com/lovecoding/day17/ex01/Test03.class
  40. BIN
      JavaSE/out/production/day18/com/lovecoding/day18/MyArray.class
  41. BIN
      JavaSE/out/production/day18/com/lovecoding/day18/coll01/TestCollection01.class
  42. BIN
      JavaSE/out/production/day18/com/lovecoding/day18/ex01/Student.class
  43. BIN
      JavaSE/out/production/day18/com/lovecoding/day18/ex01/TestStudent$1.class
  44. BIN
      JavaSE/out/production/day18/com/lovecoding/day18/ex01/TestStudent.class
  45. BIN
      JavaSE/out/production/day18/com/lovecoding/day18/ex02/Employee.class
  46. BIN
      JavaSE/out/production/day18/com/lovecoding/day18/ex02/EmployeeAgeComparator.class
  47. BIN
      JavaSE/out/production/day18/com/lovecoding/day18/ex02/TestEmployee$1.class
  48. BIN
      JavaSE/out/production/day18/com/lovecoding/day18/ex02/TestEmployee.class
  49. BIN
      JavaSE/out/production/day18/com/lovecoding/day18/ex03/Coordinate.class
  50. BIN
      JavaSE/out/production/day18/com/lovecoding/day18/ex03/TestCoordinate.class
  51. BIN
      JavaSE/out/production/day18/com/lovecoding/day18/fanxing01/Student.class
  52. BIN
      JavaSE/out/production/day18/com/lovecoding/day18/fanxing01/TestFanXing.class
  53. BIN
      JavaSE/out/production/day18/com/lovecoding/day18/iterator01/TestIterator.class
  54. BIN
      JavaSE/out/production/day18/com/lovecoding/day18/iterator01/TestIterator2.class
  55. BIN
      JavaSE/out/production/day19/com/lovecoding/day19/ex01/Test01.class
  56. BIN
      JavaSE/out/production/day19/com/lovecoding/day19/ex02/TestStudent.class
  57. BIN
      JavaSE/out/production/day19/com/lovecoding/day19/list01/TestLinkedList.class
  58. BIN
      JavaSE/out/production/day19/com/lovecoding/day19/list01/TestList.class
  59. BIN
      JavaSE/out/production/day19/com/lovecoding/day19/list01/TestListIterator.class
  60. BIN
      JavaSE/out/production/day19/com/lovecoding/day19/list01/TestStack.class
  61. BIN
      JavaSE/out/production/day19/com/lovecoding/day19/list01/TestVector.class
  62. BIN
      JavaSE/out/production/day19/com/lovecoding/day19/map01/TestMap01.class
  63. BIN
      JavaSE/out/production/day19/com/lovecoding/day19/set01/Person.class
  64. BIN
      JavaSE/out/production/day19/com/lovecoding/day19/set01/TestLinkedHashSet.class
  65. BIN
      JavaSE/out/production/day19/com/lovecoding/day19/set01/TestSet.class
  66. BIN
      JavaSE/out/production/day19/com/lovecoding/day19/set01/TestTreeSet$1.class
  67. BIN
      JavaSE/out/production/day19/com/lovecoding/day19/set01/TestTreeSet.class

+ 3 - 0
JavaSE/.idea/modules.xml

@@ -17,6 +17,9 @@
       <module fileurl="file://$PROJECT_DIR$/day14/day14.iml" filepath="$PROJECT_DIR$/day14/day14.iml" />
       <module fileurl="file://$PROJECT_DIR$/day15/day15.iml" filepath="$PROJECT_DIR$/day15/day15.iml" />
       <module fileurl="file://$PROJECT_DIR$/day16/day16.iml" filepath="$PROJECT_DIR$/day16/day16.iml" />
+      <module fileurl="file://$PROJECT_DIR$/day17/day17.iml" filepath="$PROJECT_DIR$/day17/day17.iml" />
+      <module fileurl="file://$PROJECT_DIR$/day18/day18.iml" filepath="$PROJECT_DIR$/day18/day18.iml" />
+      <module fileurl="file://$PROJECT_DIR$/day19/day19.iml" filepath="$PROJECT_DIR$/day19/day19.iml" />
     </modules>
   </component>
 </project>

+ 21 - 0
JavaSE/day17/day17.iml

@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="JAVA_MODULE" version="4">
+  <component name="NewModuleRootManager" inherit-compiler-output="true">
+    <exclude-output />
+    <content url="file://$MODULE_DIR$">
+      <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
+    </content>
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+    <orderEntry type="module-library">
+      <library name="JUnit4">
+        <CLASSES>
+          <root url="jar://$MAVEN_REPOSITORY$/junit/junit/4.13.1/junit-4.13.1.jar!/" />
+          <root url="jar://$MAVEN_REPOSITORY$/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+  </component>
+</module>

+ 281 - 0
JavaSE/day17/src/com/lovecoding/day17/api/TestString.java

@@ -0,0 +1,281 @@
+package com.lovecoding.day17.api;
+
+import org.junit.Test;
+
+import java.io.UnsupportedEncodingException;
+import java.nio.charset.StandardCharsets;
+import java.util.Arrays;
+
+public class TestString {
+
+    //(32)String[] split(正则):按照某种规则进行拆分
+    @Test
+    public void test12(){
+        String s1 = "h.e.llo.wor.ld";
+        String s2 = "h[e[llo[wor[ld";
+        String[] split1 = s1.split("\\.");
+        String[] split2 = s2.split("\\[");
+        System.out.println(Arrays.toString(split1));
+        System.out.println(Arrays.toString(split2));
+
+        String[] os = s1.split("o");
+        System.out.println(Arrays.toString(os));
+    }
+
+
+    //(29)String replace(xx,xx):不支持正则
+    //(30)String replaceFirst(正则,value):替换第一个匹配部分
+    //(31)String repalceAll(正则, value):替换所有匹配部分
+    @Test
+    public void test11(){
+        //String replace(xx,xx):不支持正则
+        String a1 = "Process finished with exit code 0";
+        String code = a1.replace("code", "");
+        System.out.println(code);
+
+        //String replaceFirst(正则,value):替换第一个匹配部分
+        String a2 = "替换第一个匹配部分,替换所有匹配部分";
+        String s = a2.replaceFirst("替换", "aaaaa");
+        System.out.println(s);
+
+        //String repalceAll(正则, value):替换所有匹配部分
+        String a3 = " hello world ";
+        String s1 = a3.replaceAll(" ", "");
+        System.out.println(s1);
+
+    }
+
+    //boolean matchs(正则表达式):判断当前字符串是否匹配某个正则表达式
+    @Test
+    public void test10(){
+        //qq要求 5-11位 数字组成  第一位 1-9
+        String qq = "5678";
+        //第一位1-9 第2位 第11位 0-0组成
+        String reg = "[1-9][0-9]{4,10}+";
+
+        System.out.println(qq.matches(reg));
+    }
+
+    /*
+    (26)boolean startsWith(xx):是否以xx开头
+    (27)boolean endsWith(xx):是否以xx结尾
+     */
+    @Test
+    public void test09(){
+        String s1 = "中国歩军天下无敌,中国空军世界前列";
+        System.out.println(s1.startsWith("中国"));
+        System.out.println(s1.endsWith("世界"));
+
+    }
+
+    /*
+    (11)boolean contains(xx):是否包含xx
+    (12)int indexOf(xx):从前往后找当前字符串中xx,即如果有返回第一次出现的下标,要是没有返回-1
+    (13)int lastIndexOf(xx):从后往前找当前字符串中xx,即如果有返回最后一次出现的下标,要是没有返回-1
+     */
+    @Test
+    public void test08(){
+        //boolean contains(xx):是否包含xx
+        System.out.println("helloworld".contains("h"));
+        System.out.println("helloworld".contains("a"));
+
+        //int indexOf(xx):从前往后找当前字符串中xx,即如果有返回第一次出现的下标,要是没有返回-1
+        String  s1 =  "中国歩军天下无敌,中国空军世界前列";
+        System.out.println(s1.indexOf("中国"));
+        //截取第一个中国
+        String substring = s1.substring(s1.indexOf("天下"), "中国".length() + s1.indexOf("天下"));
+        System.out.println(substring);
+
+        System.out.println(s1.lastIndexOf("中国"));
+    }
+
+    /*
+    (24)byte[] getBytes():编码,把字符串变为字节数组,按照平台默认的字符编码方式进行编码
+        byte[] getBytes(字符编码方式):按照指定的编码方式进行编码
+   (25)new String(byte[] ) 或 new String(byte[], int, int):解码,按照平台默认的字符编码进行解码
+       new String(byte[],字符编码方式 ) 或 new String(byte[], int, int,字符编码方式):解码,按照指定的编码方式进行解码
+     */
+    @Test
+    public void test07() throws UnsupportedEncodingException {
+        byte[] bytes = "中国".getBytes();
+        byte[] bytes1 = "中国".getBytes(StandardCharsets.ISO_8859_1); //ISO_8859_1 不能存储中文
+
+        String s = new String(bytes);
+        System.out.println(s);
+
+        System.out.println(Arrays.toString(bytes));
+        String s1 = new String(bytes1,StandardCharsets.ISO_8859_1);//
+        System.out.println(s1);
+
+        //GBK  两个字节  UTF8 三个字节
+        byte[] bytes2 = "中国".getBytes(); //u8
+        System.out.println(Arrays.toString(bytes));
+        byte[] gbks = "中国".getBytes("GBK");//GBK
+        System.out.println(Arrays.toString(gbks));
+    }
+    /*
+    (16)char charAt(index):返回[index]位置的字符
+    (17)char[] toCharArray(): 将此字符串转换为一个新的字符数组返回
+    (18)String(char[] value):返回指定数组中表示该字符序列的 String。
+    (19)String(char[] value, int offset, int count):返回指定数组中表示该字符序列的 String。
+    (20)static String copyValueOf(char[] data): 返回指定数组中表示该字符序列的 String
+    (21)static String copyValueOf(char[] data, int offset, int count):返回指定数组中表示该字符序列的 String
+    (22)static String valueOf(char[] data, int offset, int count) : 返回指定数组中表示该字符序列的 String
+    (23)static String valueOf(char[] data)  :返回指定数组中表示该字符序列的 String
+     */
+    @Test
+    public void test06(){
+        String s = "helloworld";
+        //char charAt(index):返回[index]位置的字符
+        char c = s.charAt(3);
+        System.out.println(c);
+        //char[] toCharArray(): 将此字符串转换为一个新的字符数组返回
+        char[] chars = s.toCharArray();
+        System.out.println(Arrays.toString(chars));
+
+        //static String copyValueOf(char[] data): 返回指定数组中表示该字符序列的 String
+        String s1 = "helloworld";
+        char[] chars1 = s1.toCharArray();
+        String s2 = String.copyValueOf(chars1);
+        String s3 = String.copyValueOf(chars1,0,2);
+        System.out.println(s2);
+        System.out.println(s3);
+
+    }
+
+    @Test
+    public void test05(){
+        //#### 字符串截取
+        //(14)String substring(int beginIndex) :返回一个新的字符串,它是此字符串的从beginIndex开始截取到最后的一个子字符串。
+        //(15)String substring(int beginIndex, int endIndex) :返回一个新字符串,它是此字符串从beginIndex开始截取到endIndex(不包含)的一个
+        String substring = "abcdefg".substring(2);
+        System.out.println(substring);
+
+        String a = "helloworld";
+        String substring1 = a.substring(4, 7);
+        System.out.println(substring1);
+
+        //截取 a 字符串 从3开到最后
+        String a1 = "helloworld"; // l = 10
+
+        String substring2 = a1.substring(3, a1.length());
+        System.out.println(substring2);
+    }
+
+    /*
+      (1)  boolean isEmpty():字符串是否为空
+    (2)int length():返回字符串的长度
+    (3)String concat(xx):拼接,等价于+
+    (4)boolean equals(Object obj):比较字符串是否相等,区分大小写
+    (5)boolean equalsIgnoreCase(Object obj):比较字符串是否相等,不区分大小写
+    (6)int compareTo(String other):比较字符串大小,区分大小写,按照Unicode编码值比较大小
+    (7)int compareToIgnoreCase(String other):比较字符串大小,不区分大小写
+    (8)String toLowerCase():将字符串中大写字母转为小写
+    (9)String toUpperCase():将字符串中小写字母转为大写
+    (10)String trim():去掉字符串前后空白符
+    (11)public String intern():结果在常量池中共享
+     */
+    @Test
+    public void test04(){
+        String s1 = "a";
+        //boolean isEmpty():字符串是否为空
+        System.out.println(s1.isEmpty());
+        //int length():返回字符串的长度
+        System.out.println("abc".length());
+        //String concat(xx):拼接,等价于+
+        System.out.println("hello".concat("world"));
+        //boolean equals(Object obj):比较字符串是否相等,区分大小写
+        //boolean equalsIgnoreCase(Object obj):比较字符串是否相等,不区分大小写
+        System.out.println("abc".equals("ab"));
+        System.out.println("abc".equalsIgnoreCase("ABC"));
+        //int compareTo(String other):比较字符串大小,区分大小写,按照Unicode编码值比较大小
+        System.out.println("a".compareTo("b")); //-1
+        System.out.println("a".compareTo("a")); //0
+        System.out.println("c".compareTo("a")); //2
+        //String toUpperCase():将字符串中小写字母转为大写
+        System.out.println("abc".toUpperCase());
+        //String trim():去掉字符串前后空白符
+        System.out.println(" hello   world ".trim());
+        //public String intern():结果在常量池中共享
+        String a2 = "abc";
+        String a3 = "a";
+        String a4 = (a3+"bc").intern();
+        System.out.println(a4==a2);
+
+
+    }
+
+    //字符串的对象的个数
+    @Test
+    public void test03(){
+        String a1 = "abc"; //abc 常量
+        String a2 = new String("a");  // new String("a") 堆中  常量池 "a"
+
+        //创建了几个对象  3
+        // abc 常量
+        // new String("a") 堆中  常量池 "a"
+
+        String a3 = "hello"; //hello 常量
+        String a4 = new String("hello");  // new String("hello") 堆中  常量池 "hello" 指向已经创建的hello
+        //创建了几个对象  2
+
+        boolean empty = "".isEmpty();
+    }
+
+    /*
+    - static String copyValueOf(char[] data): 返回指定数组中表示该字符序列的 String
+    - static String copyValueOf(char[] data, int offset, int count):返回指定数组中表示该字符序列的 String
+    - static String valueOf(char[] data)  : 返回指定数组中表示该字符序列的 String
+    - static String valueOf(char[] data, int offset, int count) : 返回指定数组中表示该字符序列的 String
+    - static String valueOf(xx  value):xx支持各种数据类型,返回各种数据类型的value参数的字符串表示形式。
+     */
+    @Test
+    public void test02(){
+        char[] arr = {'a','b','c','d'};
+        String s = String.copyValueOf(arr, 0, 2);
+        System.out.println(s);
+
+        String s1 = String.valueOf(12);
+        System.out.println(s1);
+
+        String s2 = String.valueOf(arr);
+        System.out.println(s2);
+
+    }
+
+    /*
+     * `public String() ` :初始化新创建的 String对象,以使其表示空字符序列。
+     * ` String(String original)`: 初始化一个新创建的 `String` 对象,使其表示一个与参数相同的字符序列;换句话说,新创建的字符串是该参数字符串的副本。
+     * `public String(char[] value) ` :通过当前参数中的字符数组来构造新的String。
+     * `public String(char[] value,int offset, int count) ` :通过字符数组的一部分来构造新的String。
+     * `public String(byte[] bytes) ` :通过使用平台的默认字符集解码当前参数中的字节数组来构造新的String。
+     * `public String(byte[] bytes,String charsetName) ` :通过使用指定的字符集解码当前参数中的字节数组来构造新的String。
+     */
+
+    @Test
+    public void test01() throws UnsupportedEncodingException {
+        String a1 = "abc"; //直接指向常量
+        String a2 = new String("abc"); //通过堆内存指向常量池中的abc常量
+
+        System.out.println(a1==a2);
+
+        String a3 = new String();
+        if ( a3 != null && a3.length()==0){
+            System.out.println("空字符串");
+        }
+
+        //char数组
+        char[] chars = {'a','b','c'};
+        String a4 = new String(chars);
+
+        System.out.println(a4);
+
+        byte[] bytes = "中国".getBytes("GBK");
+        System.out.println(Arrays.toString(bytes));
+
+        String a5 = new String(bytes,"GBK");
+        System.out.println(a5);
+
+    }
+
+}

+ 77 - 0
JavaSE/day17/src/com/lovecoding/day17/api/TestStringBuffer.java

@@ -0,0 +1,77 @@
+package com.lovecoding.day17.api;
+
+import org.junit.Test;
+
+public class TestStringBuffer {
+
+    //(1)StringBuffer append(xx):拼接,追加
+    //(2)StringBuffer insert(int index, xx):在[index]位置插入xx
+    //(3)StringBuffer delete(int start, int end):删除[start,end)之间字符
+    //StringBuffer deleteCharAt(int index):删除[index]位置字符
+    //(4)void setCharAt(int index, xx):替换[index]位置字符
+    //(5)StringBuffer reverse():反转
+    //(6)void setLength(int newLength) :设置当前字符序列长度为newLength
+    //(7)StringBuffer replace(int start, int end, String str):替换[start,end)范围的字符序列为str
+    //(8)int indexOf(String str):在当前字符序列中查询str的第一次出现下标
+    //​          int indexOf(String str, int fromIndex):在当前字符序列[fromIndex,最后]中查询str的第一次出现下标
+    //​         int lastIndexOf(String str):在当前字符序列中查询str的最后一次出现下标
+    //​         int lastIndexOf(String str, int fromIndex):在当前字符序列[fromIndex,最后]中查询str的最后一次出现下标
+    //(9)String substring(int start):截取当前字符序列[start,最后]
+    //(10)String substring(int start, int end):截取当前字符序列[start,end)
+    //(11)String toString():返回此序列中数据的字符串表示形式
+
+    @Test
+    public void test02(){
+        //(6)void setLength(int newLength) :设置当前字符序列长度为newLength
+        StringBuffer sb1 = new StringBuffer();
+        System.out.println(sb1.length());
+
+        StringBuffer sb2 = new StringBuffer(10);
+        sb2.append("java");
+        System.out.println(sb2.length());
+
+        StringBuffer sb3 = new StringBuffer();
+        sb3.setLength(10);
+        System.out.println(sb3.length());
+
+        //(7)StringBuffer replace(int start, int end, String str):替换[start,end)范围的字符序列为str
+        StringBuffer sb = new StringBuffer("java");
+        System.out.println(sb.replace(0, 2, "aaa"));
+        //(8)int indexOf(String str):在当前字符序列中查询str的第一次出现下标
+
+        StringBuffer sb4 = new StringBuffer("helloworldjava");
+        int a = sb4.indexOf("a");
+        System.out.println(a);
+        //​          int indexOf(String str, int fromIndex):在当前字符序列[fromIndex,最后]中查询str的第一次出现下标
+        //​         int lastIndexOf(String str):在当前字符序列中查询str的最后一次出现下标
+        //​         int lastIndexOf(String str, int fromIndex):在当前字符序列[fromIndex,最后]中查询str的最后一次出现下标
+        //(9)String substring(int start):截取当前字符序列[start,最后]
+        StringBuffer sb5 = new StringBuffer("helloworldjava");
+        String substring1 = sb5.substring(6);
+        String substring2 = sb5.substring(0,5);
+        System.out.println(substring1);
+        System.out.println(substring2);
+        //(10)String substring(int start, int end):截取当前字符序列[start,end)
+    }
+
+    @Test
+    public void test01(){
+        //(1)StringBuffer append(xx):拼接,追加
+        StringBuffer stringBuffer = new StringBuffer("hello");
+        stringBuffer.append("world").append("java");
+        //转String的方法
+        System.out.println(stringBuffer+"");
+        System.out.println(stringBuffer.toString());
+        //(2)StringBuffer insert(int index, xx):在[index]位置插入xx
+        stringBuffer.insert(0,"a");
+        //(3)StringBuffer delete(int start, int end):删除[start,end)之间字符
+        stringBuffer.delete(0,2);
+        //StringBuffer deleteCharAt(int index):删除[index]位置字符
+        stringBuffer.deleteCharAt(0);
+        //(4)void setCharAt(int index, xx):替换[index]位置字符
+        stringBuffer.setCharAt(0,'a');
+        //(5)StringBuffer reverse():反转
+        System.out.println(stringBuffer.reverse().toString());
+    }
+
+}

+ 57 - 0
JavaSE/day17/src/com/lovecoding/day17/ex01/Test01.java

@@ -0,0 +1,57 @@
+package com.lovecoding.day17.ex01;
+
+import org.junit.Test;
+
+import java.util.Arrays;
+
+public class Test01 {
+
+    @Test
+    public void test02(){
+        //案例:有一个字符串String abc = “342567891”,请写程序将字符串abc进行升序,可以使用JDK API中的现有的功能方法。
+        String abc = "342567891";
+        //转换
+        char[] chars = abc.toCharArray();
+
+        //排序
+        Arrays.sort(chars);
+
+        System.out.println(Arrays.toString(chars));
+
+    }
+
+    @Test
+    public void test01(){
+        //定义数组,存入多个字符串。删除长度大于5的字符串,打印删除后的数组。
+        String[] arr = {"heilongjiang","java","haerbin","c++","python","js","javascript"};
+        /*
+        {"heilongjiang","java","haerbin","c++","python","js","javascript"}
+        {"java","haerbin","c++","python","js","javascript}
+        {"java","haerbin","c++","python","js","javascript}
+        {"java","c++","python","js","javascript}
+        {"java","c++",,"js","javascript}
+        {"java","c++",,"js"}
+         */
+        int count = arr.length;
+
+        //循环
+        for (int i = 0; i < count; i++) {
+            if (arr[i].length()>5){
+                //Params:
+                //src – the source array.
+                //srcPos – starting position in the source array.
+                //dest – the destination array.
+                //destPos – starting position in the destination data.
+                //length – the number of array elements to be copied.
+                System.arraycopy(arr,i+1,arr,i,count-1-i);
+                i--;
+                count--;
+            }
+        }
+
+        String[] strings = Arrays.copyOf(arr, count);
+        System.out.println(Arrays.toString(strings));
+
+    }
+
+}

+ 159 - 0
JavaSE/day17/src/com/lovecoding/day17/ex01/Test02.java

@@ -0,0 +1,159 @@
+package com.lovecoding.day17.ex01;
+
+import org.junit.Test;
+
+import java.util.Arrays;
+
+public class Test02 {
+
+    //1个字符串中可能包含a-z中的多个字符,字符也可能重复,例如:String data = “aabcexmkduyruieiopxzkkkkasdfjxjdsds”;
+    //写一个程序,对于给定一个这样的字符串求出字符串出现次数最多的那个字母以及出现的次数(若次数最多的字母有多个,则全部求出)
+    //提示:
+    //- 数组 长度 26  0索引 a 1代表b   int
+    //- 字符-97 == 0   该位置++
+    @Test
+    public void test04(){
+        //26数组
+        int[] arr = new int[26];
+
+        //字符串
+        String str = "aaaabcexmkduyruieiopxzkkkkasdfjxjdsds";
+
+        char[] chars = str.toCharArray();
+        for (int i = 0; i < chars.length; i++) {
+            arr[chars[i]-97]++;
+        }
+        //arr
+        //[3, 1, 1, 4, 2, 1, 0, 0, 2, 2, 5, 0, 1, 0, 1, 1, 0, 1, 3, 0, 2, 0, 0, 3, 1, 1]
+        // a  b  c  d  e  f  g  h  i  j  k
+        System.out.println(Arrays.toString(arr));
+
+        //找最值
+        int max = arr[0];
+        int index = 0;
+        for (int i = 0; i < arr.length; i++) {
+            if (arr[i]>max){
+                max = arr[i];
+                index = i;
+            }
+        }
+//        System.out.println("max:"+max);
+//
+//        System.out.println((char) (index+97));
+
+        //
+        for (int i = 0; i < arr.length; i++) {
+            if (arr[i]==max){
+                System.out.println("max:"+arr[i]);
+                System.out.println((char) (i+97));
+            }
+        }
+    }
+
+
+    //获取一个字符串在另一个字符串中出现的次数。比如:获取"ab"在 “abababkkcadkabkebfkabkskab”中出现的次数
+    @Test
+    public void test03(){
+        int count = count1("ab", "abababkkcadkabkebfkabkskab");
+        System.out.println(count);
+    }
+    private int count1(String mstr, String maxstr ) {
+        int length = maxstr.replaceAll(mstr, "").length();
+        return (maxstr.length() - length) / mstr.length();
+    }
+
+    private int count(String mstr, String maxstr ) {
+
+        int count = 0;
+
+        while (maxstr.contains(mstr)){
+            maxstr = maxstr.replaceFirst(mstr, "");
+            count++;
+        }
+        return count;
+    }
+
+    //将字符串中指定部分进行反转。比如将“abcdefgho”实现部分反转,结果为”abfedcgho”
+    @Test
+    public void test02(){
+        String s1 = "helloworld";
+        String resver = resver2(s1, 1, 5);
+        System.out.println(resver);
+    }
+    public String resver2(String str,int s , int e){
+        String left = str.substring(0, s);
+        String m = str.substring(s, e);
+        String right = str.substring(e, str.length());
+
+        //StringBuffer
+        StringBuffer sb = new StringBuffer(m);
+        StringBuffer reverse = sb.reverse();
+        return left + reverse.toString() + right;
+    }
+
+    public String resver1(String str,int s , int e){
+
+        char[] chars = str.toCharArray();
+
+        for (int i = s , j = e; i <e; i++,j--) {
+            char temp = chars[i];
+            chars[i] = chars[j];
+            chars[j] = temp;
+        }
+
+        String s1 = new String(chars);
+        return s1;
+    }
+
+    //不能使用trim(),实现去除字符串两端的空格。
+    @Test
+    public void test01(){
+        //比较空串和字符' '
+        // str.startsWith(" ")
+        String s1 = "   hell   oworld    ";
+        String s = trim03(s1);
+        System.out.println(s);
+    }
+
+    public String trim03(String str){
+        String s = str.replaceAll("(^\\s+)|(\\s+$)", "");
+        return s;
+    }
+
+    public String trim02(String str){
+
+        while ( str.startsWith(" ") ){
+            str = str.replaceFirst(" ", "");
+        }
+        while ( str.endsWith(" ") ){
+            str = str.substring(0,str.length()-1);
+        }
+        return str;
+    }
+
+    public String trim01(String str){
+        char[] chars = str.toCharArray();
+        int start = 0;
+        for (int i = 0; i < chars.length; i++) {
+            //字符串和cahr比较
+            if (String.valueOf(chars[i]).equals(" ")){
+                start++;
+            }else {
+                break;
+            }
+        }
+        int end = chars.length;
+
+        for (int i = chars.length-1; 0 < chars.length; i--) {
+            if (" ".equals(String.valueOf(chars[i]))){
+                end--;
+            }else {
+                break;
+            }
+        }
+
+        String substring = str.substring(start, end);
+        return substring;
+    }
+
+}

+ 60 - 0
JavaSE/day17/src/com/lovecoding/day17/ex01/Test03.java

@@ -0,0 +1,60 @@
+package com.lovecoding.day17.ex01;
+
+import org.junit.Test;
+
+import java.util.Arrays;
+
+public class Test03 {
+
+    @Test
+    public void test01(){
+        //拆分
+        //案例:已知一个字符串内容如下,要求拆分出每一个单词,并遍历显示
+        String str = "1.hello2.world3.java4.string";
+
+        String s = str.replaceAll("1.", "");
+        String[] split = s.split("\\d.");
+        System.out.println(Arrays.toString(split));
+
+    }
+
+    //获取两个字符串中最大相同子串。
+    //比如:str1 = "abcwerthelloyuiodef“;  str2 = "cvhellobnm",最大相同子串是"hello"。
+    // 提示:将短的那个串进行长度依次递减的子串与较长的串比较。
+
+    // abcwerthelloyuiodef  cvhellobnm
+    // abcwerthelloyuiodef  cvhellobn
+    // abcwerthelloyuiodef  c
+
+    @Test
+    public void test02(){
+        String str1 = "abcwerthelloyuiodef";
+        String str2 = "cvhellobnm";
+        System.out.println(callson(str1, str2));
+    }
+
+    private String callson(String str1, String str2) {
+
+        String maxStr =  str1.length()>str2.length()? str1 : str2;
+        String minStr =  str1.length()<str2.length()? str1 : str2;
+
+        String result = "";
+        //外层控制 小的索引
+        for (int i = 0; i < minStr.length(); i++) {
+            //内
+            for (int j = 0; j < minStr.length()-i  ; j++) {
+                //System.out.println( str2.substring(i,str2.length()-j) );
+                String str = minStr.substring(i, minStr.length() - j);
+                //包含
+                if (maxStr.contains(str)){
+                    if (str.length() > result.length()){
+                        result = str;
+                    }
+                }
+            }
+        }
+        return result;
+    }
+
+
+}

+ 21 - 0
JavaSE/day18/day18.iml

@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="JAVA_MODULE" version="4">
+  <component name="NewModuleRootManager" inherit-compiler-output="true">
+    <exclude-output />
+    <content url="file://$MODULE_DIR$">
+      <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
+    </content>
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+    <orderEntry type="module-library">
+      <library name="JUnit4">
+        <CLASSES>
+          <root url="jar://$MAVEN_REPOSITORY$/junit/junit/4.13.1/junit-4.13.1.jar!/" />
+          <root url="jar://$MAVEN_REPOSITORY$/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+  </component>
+</module>

+ 63 - 0
JavaSE/day18/src/com/lovecoding/day18/MyArray.java

@@ -0,0 +1,63 @@
+package com.lovecoding.day18;
+
+import org.junit.Test;
+
+import java.util.Comparator;
+
+public class MyArray<T> {
+    /*
+    (1)在数组工具类MyArrays中声明如下泛型方法:
+    - 可以在任意类型的对象数组中,查找某个元素的下标,按照顺序查找,如果有重复的,就返回第一个找到的,如果没有返回-1
+    - 可以在任意类型的对象数组中,查找最大值,要求元素必须实现Comparable接口
+    - 可以在任意类型的对象数组中,查找最大值,按照指定定制比较器来比较元素大小
+     */
+
+    public static <T>  int  searchIndex(T[] arr, T a){
+
+        for (int i = 0; i < arr.length; i++) {
+            if (arr[i].equals(a)){
+                return i;
+            }
+        }
+        return -1;
+    }
+
+
+    public static  <T extends Comparable<T> >  T  max(T[] arr){
+
+        T t = arr[0];
+        for (int i = 0; i < arr.length; i++) {
+            if (arr[i].compareTo(t)>0){
+                t = arr[i];
+            }
+        }
+        return t;
+    }
+
+    public static  <T> T  maxAtor(T[] arr , Comparator<T> comparator){
+        T t = arr[0];
+        for (int i = 0; i < arr.length; i++) {
+            if (comparator.compare(arr[i],t)>0){
+                t = arr[i];
+            }
+        }
+
+        return t;
+    }
+
+
+
+
+
+
+    @Test
+    public void test01(){
+
+        Integer[] arr = {1,2,3,4,11};
+
+        //int i = searchIndex(arr, 2);
+        Integer max = maxAtor(arr,((o1, o2) -> o1.compareTo(o2)));
+        System.out.println(max);
+    }
+
+}

+ 214 - 0
JavaSE/day18/src/com/lovecoding/day18/coll01/TestCollection01.java

@@ -0,0 +1,214 @@
+package com.lovecoding.day18.coll01;
+
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+
+public class TestCollection01 {
+    //#### **3、查询与获取元素**
+    //
+    //(1)boolean isEmpty():判断当前集合是否为空集合。
+    //(2)boolean contains(Object obj):判断当前集合中是否存在一个与obj对象equals返回true的元素。
+    //(3)boolean containsAll(Collection<?> c):判断c集合中的元素是否在当前集合中都存在。即c集合是否是当前集合的“子集”。
+    //(4)int size():获取当前集合中实际存储的元素个数
+    //(5)Object[] toArray():返回包含当前集合中所有元素的数组
+
+    @Test
+    public void test08(){
+        Collection coll1 = new ArrayList();
+        coll1.add(1);
+        coll1.add(2);
+        coll1.add(3);
+        coll1.add(4);
+        Collection coll2 = new ArrayList();
+        coll2.add(1);
+        coll2.add(5);
+
+        //boolean containsAll(Collection<?> c):判断c集合中的元素是否在当前集合中都存在。即c集合是否是当前集合的“子集”。
+        boolean b = coll1.containsAll(coll2);
+        System.out.println(b);
+
+        //个数
+        System.out.println(coll1.size());
+
+        //数组
+        Object[] objects = coll1.toArray();
+
+        Collection<Integer> coll3 = new ArrayList();
+        coll3.add(1);
+        coll3.add(2);
+        coll3.add(3);
+        coll3.add(4);
+
+        Integer[] arr = {1,6};
+        //toArray 返回对应的数组类型集合
+        Integer[] integers = coll3.toArray(arr);
+        System.out.println(Arrays.toString(integers));
+    }
+
+    @Test
+    public void test07(){
+        Collection<Integer> l1 = new ArrayList();
+        l1.add(1);
+        l1.add(2);
+        l1.add(3);
+
+        boolean empty = l1.isEmpty();
+        System.out.println(empty);
+
+        l1.clear(); //删除清空
+        System.out.println(l1);
+
+        l1.add(1);
+        l1.add(2);
+        l1.add(3);
+
+        //2)boolean contains(Object obj):判断当前集合中是否存在一个与obj对象equals返回true的元素。
+        boolean contains = l1.contains(2);
+        System.out.println(contains);
+
+        boolean contains1 = l1.contains(4);
+        System.out.println(contains1);
+
+    }
+
+
+    //删除
+    // (1) boolean remove(Object obj) :从当前集合中删除第一个找到的与obj对象equals返回true的元素。
+    // (2)boolean removeAll(Collection<?> coll):从当前集合中删除所有与coll集合中相同的元素。即this = this - this ∩ coll
+    //(3)boolean removeIf(Predicate<? super E> filter) :删除满足给定条件的此集合的所有元素。
+    //(4)boolean retainAll(Collection<?> coll):从当前集合中删除两个集合中不同的元素,使得当前集合仅保留与c集合中的元素相同的元素,即当前集合中仅保留两个集合的交集,即this  = this ∩ coll;
+    @Test
+    public void test06() {
+        Collection<Integer> l1 = new ArrayList();
+        l1.add(1);
+        l1.add(2);
+        l1.add(3);
+        Collection<Integer> l2 = new ArrayList();
+        l2.add(2);
+        l2.add(3);
+        l2.add(4);
+        //交集
+        l1.retainAll(l2);
+        //输出
+        System.out.println(l1);
+    }
+
+    @Test
+    public void test05() {
+        Collection<String> list1 = new ArrayList();
+
+        list1.add("zhangsan");
+        list1.add("lisi");
+        list1.add("wangwu");
+
+        //长度大于 4的人名删除
+//        list1.removeIf(new Predicate<String>() {
+//            @Override
+//            public boolean test(String s) {
+//                //条件判断
+//                return s.length() > 4;
+//            }
+//        });
+        //@FunctionalInterface 只有一个未实现的方法
+        //可使用lambda
+//        list1.removeIf(new Predicate<String>() {
+//            @Override
+//            public boolean test(String s) {
+//                //条件判断
+//                return s.length() > 4;
+//            }
+//        });
+
+        //lambda表达式
+        list1.removeIf( (String s) -> {return s.length() > 4;} );
+
+        System.out.println(list1);
+    }
+
+    @Test
+    public void test04(){
+        Collection list1 = new ArrayList();
+
+        list1.add(1);
+        list1.add(2);
+        list1.add(3);
+
+        Collection list2 = new ArrayList();
+
+        list2.add(2);
+        list2.add(3);
+        list2.add(4);
+
+        //将list1的里面 在list2中有的元素删除。 删除相同的元素,留list1里面特有的
+        list1.removeAll(list2);
+
+        //输出
+        System.out.println(list1);
+
+    }
+
+    @Test
+    public void test03(){
+        Collection list = new ArrayList();
+
+        list.add("1");
+        list.add(2);
+        list.add(true);
+
+        list.remove(2);
+
+        //输出
+        System.out.println(list);
+
+    }
+
+    //#### **1、添加元素**
+    //(1)add(E obj):添加元素对象到当前集合中
+    //(2)addAll(Collection<? extends E> other):添加other集合中的所有元素对象到当前集合中,即this = this ∪ other
+    @Test
+    public void test01(){
+        //E 泛型
+        // ArrayList 有序的 有索引 可重复的
+        // 子类可以演示 Collection 接口的方法的
+        // 多态 编译看左边 必须是 Collection 有的方法 才可以调用。
+        Collection list = new ArrayList();
+
+        list.add("1");
+        list.add(2);
+        list.add(new Object());
+        list.add(true);
+
+        //查看
+        for (Object o : list) {
+            System.out.println("元素:"+ o);
+        }
+
+    }
+
+    @Test
+    public void test02(){
+
+        Collection list1 = new ArrayList();
+        list1.add(1);
+        list1.add(1);
+        list1.add(1);
+
+        Collection list2 = new ArrayList();
+        list2.add(2);
+        list2.add(2);
+        list2.add(2);
+
+
+        //将list2添加里面所有元素 list1里面
+        list1.addAll(list2);
+
+        //将list2当做一个元素添加到 list1里面
+        list1.add(list2);
+
+        System.out.println(list1);
+    }
+
+}

+ 50 - 0
JavaSE/day18/src/com/lovecoding/day18/ex01/Student.java

@@ -0,0 +1,50 @@
+package com.lovecoding.day18.ex01;
+
+public class Student {
+
+    private Integer id;
+    private String name;
+    private Integer age;
+
+    public Student() {
+    }
+
+    public Student(Integer id, String name, Integer age) {
+        this.id = id;
+        this.name = name;
+        this.age = age;
+    }
+
+    @Override
+    public String toString() {
+        return "Student{" +
+                "id=" + id +
+                ", name='" + name + '\'' +
+                ", age=" + age +
+                '}';
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public Integer getAge() {
+        return age;
+    }
+
+    public void setAge(Integer age) {
+        this.age = age;
+    }
+}

+ 79 - 0
JavaSE/day18/src/com/lovecoding/day18/ex01/TestStudent.java

@@ -0,0 +1,79 @@
+package com.lovecoding.day18.ex01;
+
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.function.Predicate;
+
+public class TestStudent {
+
+    @Test
+    public void test01(){
+
+        //创建集合
+        Collection<Student> students = new ArrayList<>();
+
+        //添加
+        Student gqq = new Student(1, "高启强", 38);
+        students.add(gqq); //@0x1122
+        students.add(new Student(2,"小龙",22));
+        students.add(new Student(3,"小虎",36));
+        students.add(new Student(4,"阿盛",38));
+        students.add(new Student(5,"阿伟",29));
+        students.add(new Student(6,"高启强",29));
+
+        //遍历
+        for (Student student : students) {
+            System.out.println(student);
+        }
+
+        //删除
+        //存储引用数据类类型  存储地址值 @0x1122
+        // new Student(1, "高启强", 38); 他的地址值 和 集合中的高启强 内容一样 地址不一样。
+        // 删除根据地址值 删除
+        boolean gqq1 = students.remove(new Student(1, "高启强", 38)); //0x1133
+        System.out.println(gqq1);
+        boolean gqq2 = students.remove(gqq); //@0x1122
+        System.out.println(gqq2);
+
+
+        //集合
+        System.out.println(students);
+
+        Integer age = gqq.getAge();
+
+        //使用Collection的removeIf方法删除和自己年龄一样的组员
+        students.removeIf(new Predicate<Student>() {
+            @Override
+            public boolean test(Student student) {
+                return student.getAge() == age;
+            }
+        });
+
+        //集合
+        System.out.println(students);
+
+        String name = gqq.getName();
+
+        //使用Iterator遍历,并根据组长姓名删除组长
+        Iterator<Student> iterator = students.iterator();
+
+        while (iterator.hasNext()){
+            Student s = iterator.next();
+            //删除
+            if (s.getName().equals(name)){
+                iterator.remove();
+            }
+        }
+
+        System.out.println(students);
+
+        for (Student student : students) {
+            System.out.println(student);
+        }
+    }
+
+
+}

+ 62 - 0
JavaSE/day18/src/com/lovecoding/day18/ex02/Employee.java

@@ -0,0 +1,62 @@
+package com.lovecoding.day18.ex02;
+
+public class Employee  implements  Comparable<Employee>{
+    //包含属性姓名(String),薪资(double),年龄(int)
+    private String name;
+    private double salary;
+    private int age;
+
+    public Employee() {
+    }
+
+    public Employee(String name, double salary, int age) {
+        this.name = name;
+        this.salary = salary;
+        this.age = age;
+    }
+
+
+    //按照薪资比较大小,薪资相同的按照姓名的自然顺序(调用String类的compareTo方法)比较大小。
+    @Override
+    public int compareTo(Employee o) { //泛型不需要强转
+        //用薪资
+        double result  = this.salary - o.getSalary();
+        //薪资相同使用姓名
+        return result == 0 ? this.name.compareTo(o.getName()) : (int) result;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public double getSalary() {
+        return salary;
+    }
+
+    public void setSalary(double salary) {
+        this.salary = salary;
+    }
+
+    public int getAge() {
+        return age;
+    }
+
+    public void setAge(int age) {
+        this.age = age;
+    }
+
+    @Override
+    public String toString() {
+        return "Employee{" +
+                "name='" + name + '\'' +
+                ", salary=" + salary +
+                ", age=" + age +
+                '}';
+    }
+
+
+}

+ 12 - 0
JavaSE/day18/src/com/lovecoding/day18/ex02/EmployeeAgeComparator.java

@@ -0,0 +1,12 @@
+package com.lovecoding.day18.ex02;
+
+import java.util.Comparator;
+
+public class EmployeeAgeComparator implements Comparator<Employee> {
+    @Override
+    public int compare(Employee o1, Employee o2) {
+        //按照员工年龄比较大小,年龄相同的按照姓名字典顺序
+        int result = o1.getAge() - o2.getAge();
+        return result == 0 ? o1.getName().compareTo(o2.getName()) : result;
+    }
+}

+ 38 - 0
JavaSE/day18/src/com/lovecoding/day18/ex02/TestEmployee.java

@@ -0,0 +1,38 @@
+package com.lovecoding.day18.ex02;
+
+import org.junit.Test;
+
+import java.util.Arrays;
+import java.util.Comparator;
+
+public class TestEmployee {
+
+    @Test
+    public void test01(){
+
+        Employee[] arr = {
+                new Employee("zs1",1200,10),
+                new Employee("zs2",1200,22),
+                new Employee("zs3",1400,22),
+                new Employee("zs4",1100,24),
+        };
+
+        Arrays.sort(arr);
+
+        System.out.println(Arrays.toString(arr));
+
+        //数组
+        Arrays.sort(arr,new EmployeeAgeComparator());
+
+        Arrays.sort(arr, new Comparator<Employee>() {
+            @Override
+            public int compare(Employee o1, Employee o2) {
+                //按照员工年龄比较大小,年龄相同的按照姓名字典顺序
+                int result = o1.getAge() - o2.getAge();
+                return result == 0 ? o1.getName().compareTo(o2.getName()) : result;
+            }
+        });
+
+        System.out.println(Arrays.toString(arr));
+    }
+}

+ 39 - 0
JavaSE/day18/src/com/lovecoding/day18/ex03/Coordinate.java

@@ -0,0 +1,39 @@
+package com.lovecoding.day18.ex03;
+
+public class Coordinate <T>{
+
+    private T x;
+    private T y;
+
+    public Coordinate(T x, T y) {
+        this.x = x;
+        this.y = y;
+    }
+
+    public Coordinate() {
+    }
+
+    public T getX() {
+        return x;
+    }
+
+    public void setX(T x) {
+        this.x = x;
+    }
+
+    public T getY() {
+        return y;
+    }
+
+    public void setY(T y) {
+        this.y = y;
+    }
+
+    @Override
+    public String toString() {
+        return "Coordinate{" +
+                "x=" + x +
+                ", y=" + y +
+                '}';
+    }
+}

+ 18 - 0
JavaSE/day18/src/com/lovecoding/day18/ex03/TestCoordinate.java

@@ -0,0 +1,18 @@
+package com.lovecoding.day18.ex03;
+
+import org.junit.Test;
+
+public class TestCoordinate {
+
+    @Test
+    public void test01(){
+
+        Coordinate<String> coordinate1 = new Coordinate<>("10","20");
+        Coordinate<Double> coordinate2 = new Coordinate<>(10.0,20.0);
+
+        System.out.println(coordinate1);
+        System.out.println(coordinate2);
+
+
+    }
+}

+ 50 - 0
JavaSE/day18/src/com/lovecoding/day18/fanxing01/Student.java

@@ -0,0 +1,50 @@
+package com.lovecoding.day18.fanxing01;
+
+public class Student {
+
+    private Integer id;
+    private String name;
+    private Integer age;
+
+    public Student() {
+    }
+
+    public Student(Integer id, String name, Integer age) {
+        this.id = id;
+        this.name = name;
+        this.age = age;
+    }
+
+    @Override
+    public String toString() {
+        return "Student{" +
+                "id=" + id +
+                ", name='" + name + '\'' +
+                ", age=" + age +
+                '}';
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public Integer getAge() {
+        return age;
+    }
+
+    public void setAge(Integer age) {
+        this.age = age;
+    }
+}

+ 72 - 0
JavaSE/day18/src/com/lovecoding/day18/fanxing01/TestFanXing.java

@@ -0,0 +1,72 @@
+package com.lovecoding.day18.fanxing01;
+
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+
+public class TestFanXing {
+
+    @Test
+    public void test03(){
+        //泛型方法的使用
+        List<Integer> list = Arrays.asList(1, 2, 3, 4, 5);
+
+        for (Integer integer : list) {
+            System.out.println(integer);
+        }
+
+    }
+
+    @Test
+    public void test02(){
+
+        Collection<Student> collection = new ArrayList();
+
+//        collection.add(true);
+//        collection.add("hello");
+//        collection.add(new int[]{1,2});
+        collection.add(new Student(1,"zs",22));
+//        collection.add("world");
+
+        //除了Student类型其他都会报错 避免转换异常
+        // 集合中只能有 student类型
+
+    }
+
+    @Test
+    public void test01(){
+
+        Collection collection = new ArrayList();
+
+        collection.add(true);
+        collection.add("hello");
+        collection.add(new int[]{1,2});
+        collection.add(new Student(1,"zs",22));
+        collection.add("world");
+
+        for (Object o : collection) {
+
+            if ( o instanceof Boolean ){
+                System.out.println(o);
+            }
+
+            if (o instanceof String){
+                System.out.println(o+"world");
+            }
+
+            if (o instanceof int[]){
+                System.out.println(o);
+            }
+
+            //强制转换
+            Student s = (Student) o;
+            System.out.println(s);
+
+        }
+
+    }
+
+}

+ 31 - 0
JavaSE/day18/src/com/lovecoding/day18/iterator01/TestIterator.java

@@ -0,0 +1,31 @@
+package com.lovecoding.day18.iterator01;
+
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+
+public class TestIterator {
+
+    @Test
+    public void test01(){
+
+        Collection<String> coll = new ArrayList<>();
+
+        coll.add("1");
+        coll.add("2");
+        coll.add("3");
+        coll.add("4");
+
+        //获取迭代器
+        Iterator<String> iterator = coll.iterator();
+        //遍历
+        while ( iterator.hasNext() ){
+            //获取元素
+            String next = iterator.next();
+            System.out.println(next);
+        }
+
+    }
+}

+ 74 - 0
JavaSE/day18/src/com/lovecoding/day18/iterator01/TestIterator2.java

@@ -0,0 +1,74 @@
+package com.lovecoding.day18.iterator01;
+
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+
+public class TestIterator2 {
+
+    @Test
+    public void test01(){
+
+        Collection<String> coll = new ArrayList<>();
+
+        coll.add("1");
+        coll.add("2");
+        coll.add("3");
+        coll.add("4");
+
+        //获取迭代器
+        Iterator<String> iterator = coll.iterator();
+        //遍历
+        while ( iterator.hasNext() ){
+            //获取元素
+            String next = iterator.next();
+            if (next.equals("2")){
+                coll.add("21");
+            }
+            System.out.println(next);
+        }
+
+        // 集合 = 工人获取元素。 交给迭代器。
+        // 集合 不允许操作元素 (添加 删除)
+        // 异常  ConcurrentModificationException
+
+        // 迭代器可以操作
+
+
+
+    }
+    @Test
+    public void test02(){
+
+        Collection<String> coll = new ArrayList<>();
+
+        coll.add("1");
+        coll.add("2");
+        coll.add("3");
+        coll.add("4");
+
+        //获取迭代器
+        Iterator<String> iterator = coll.iterator();
+        //遍历
+        while ( iterator.hasNext() ){
+            //获取元素
+            String next = iterator.next();
+            if (next.equals("2")){
+                //删除
+                iterator.remove();
+            }
+            System.out.println(next);
+        }
+        System.out.println("------");
+
+        System.out.println(coll);
+        // 集合 = 工人获取元素。 交给迭代器。
+        // 集合 不允许操作元素 (添加 删除)
+        // 异常  ConcurrentModificationException
+
+        // 迭代器可以操作
+
+    }
+}

+ 21 - 0
JavaSE/day19/day19.iml

@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="JAVA_MODULE" version="4">
+  <component name="NewModuleRootManager" inherit-compiler-output="true">
+    <exclude-output />
+    <content url="file://$MODULE_DIR$">
+      <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
+    </content>
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+    <orderEntry type="module-library">
+      <library name="JUnit4">
+        <CLASSES>
+          <root url="jar://$MAVEN_REPOSITORY$/junit/junit/4.13.1/junit-4.13.1.jar!/" />
+          <root url="jar://$MAVEN_REPOSITORY$/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+  </component>
+</module>

+ 97 - 0
JavaSE/day19/src/com/lovecoding/day19/ex01/Test01.java

@@ -0,0 +1,97 @@
+package com.lovecoding.day19.ex01;
+
+import org.junit.Test;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Random;
+import java.util.Set;
+
+public class Test01 {
+
+    //随机产生10 个50 以内的随机数(不重复) ,存放到HashSet中,最后使用foreach循环遍历显示它们。保证最后Set中有10个元素。
+    @Test
+    public void test04() {
+        //set
+        Set<Integer> set = new HashSet<>();
+        //循环
+        while (set.size() < 10) {
+            //随机数
+            int i1 = new Random().nextInt(50);
+            //判断是否是偶数
+            if (i1 % 2 == 0) {
+                set.add(i1);
+            }
+        }
+
+        System.out.println(set);
+
+    }
+
+
+    //随机产生几个100以内的偶数,存放到HashSet中,并且使用Iterator迭代器遍历显示它们,保证最后Set中有10个元素。
+    @Test
+    public void test03(){
+        //set
+        Set<Integer> set = new HashSet<>();
+        //循环
+        while ( set.size() < 10 ){
+            //随机数
+            int i1 = new Random().nextInt(100);
+            //判断是否是偶数
+            if ( i1 % 2 == 0 ){
+                set.add(i1);
+            }
+        }
+        //迭代器
+        Iterator<Integer> iterator = set.iterator();
+
+        while (iterator.hasNext()){
+            System.out.print(iterator.next()+", ");
+        }
+    }
+
+    //随机产生10个100以内的偶数,存放到一个Set集合中,然后获取元素的个数,最后使用foreach循环遍历显示它们。
+    @Test
+    public void test02(){
+        //set
+        Set<Integer> set = new HashSet<>();
+        //循环
+        while ( set.size() < 10 ){
+            //随机数
+            int i1 = new Random().nextInt(100);
+            //判断是否是偶数
+            if ( i1 % 2 == 0 ){
+                set.add(i1);
+            }
+        }
+        //获取个数
+        System.out.println("个数"+set.size());
+        //循环遍历
+        for (Integer integer : set) {
+            System.out.print(integer+", ");
+        }
+    }
+
+
+    @Test
+    public void test01(){
+        //set
+        Set<Integer> set = new HashSet<>();
+        //循环
+        for (int i = 0; i < 10; i++) {
+            //随机数
+            int i1 = new Random().nextInt(100);
+            //判断是否是偶数
+            if ( i1 % 2 == 0 ){
+                set.add(i1);
+            }
+        }
+        //获取个数
+        System.out.println(set.size());
+        //循环遍历
+        for (Integer integer : set) {
+            System.out.println(integer);
+        }
+    }
+}

+ 63 - 0
JavaSE/day19/src/com/lovecoding/day19/ex02/TestStudent.java

@@ -0,0 +1,63 @@
+package com.lovecoding.day19.ex02;
+
+import org.junit.Test;
+
+import java.util.*;
+
+public class TestStudent {
+
+    //(1)创建HashMap对象,泛型为<String, ArrayList<String>>,
+    //(2)存储咱们班每组学员信息,组长姓名为key,组员们的姓名(包括组长自己)为value
+    //(2)遍历显示每一个小组信息
+    //(3)从键盘输入一个学员姓名,查找这个学员是否咱们班
+
+    @Test
+    public void test01(){
+        //(1)创建HashMap对象,泛型为<String, ArrayList<String>>,
+        HashMap<String, ArrayList<String>> map = new HashMap<>();
+
+        //创建组员集合
+        ArrayList<String> list1 = new ArrayList<>();
+        list1.add("高启强");
+        list1.add("高启盛");
+        list1.add("高启兰");
+
+        //存储咱们班每组学员信息,组长姓名为key,组员们的姓名(包括组长自己)为value
+        map.put("高启强",list1);
+
+        //创建组员集合
+        ArrayList<String> list2 = new ArrayList<>();
+        list2.add("安心");
+        list2.add("小五");
+        list2.add("李响");
+
+        //存储咱们班每组学员信息,组长姓名为key,组员们的姓名(包括组长自己)为value
+        map.put("安心",list2);
+
+        //遍历显示每一个小组信息
+        Set<Map.Entry<String, ArrayList<String>>> entries = map.entrySet();
+        //输出组信息
+        for (Map.Entry<String, ArrayList<String>> entry : entries) {
+            System.out.print("组长:"+entry.getKey());
+            ArrayList<String> value = entry.getValue();
+            //拼接
+            StringBuffer sb = new StringBuffer();
+            for (String s : value) {
+                sb.append(s).append(", ");
+            }
+            System.out.print(" 组员:"+ sb.toString()  );
+
+            System.out.println();
+        }
+
+        //合并两个组
+        list1.addAll(list2);
+
+        String s =  "安心";
+
+        System.out.println(list1.contains(s));
+
+        //遍历所有的 value中的 元素 添加到一个集合里面。
+
+    }
+}

+ 68 - 0
JavaSE/day19/src/com/lovecoding/day19/list01/TestLinkedList.java

@@ -0,0 +1,68 @@
+package com.lovecoding.day19.list01;
+
+import org.junit.Test;
+
+import java.util.LinkedList;
+
+public class TestLinkedList {
+
+
+
+    /*
+        E pop() 弹出此列表所代表的堆栈中的元素。
+        void push(E e) 将元素推送到此列表所表示的堆栈上。
+        void addFirst(E e) 在此列表的开头插入指定的元素。
+
+        E getFirst() 返回此列表中的第一个元素。
+
+     */
+
+    @Test
+    public void test02(){
+        LinkedList<Integer> list = new LinkedList<>();
+        list.push(11);
+        list.push(22);
+        list.push(33);
+        //先进后出
+        //[ 33, 22, 11]
+
+//        Integer pop1 = list.pop();
+//        Integer pop2 = list.pop();
+//        Integer pop3 = list.pop();
+//
+//        System.out.println(pop1);
+//        System.out.println(pop2);
+//        System.out.println(pop3);
+
+        Integer last = list.getLast();
+        System.out.println(last);
+
+
+    }
+    @Test
+    public void test01(){
+
+        LinkedList<Integer> list = new LinkedList<>();
+        list.addFirst(11);
+        list.addFirst(22);
+        list.addFirst(33);
+
+        System.out.println(list);
+
+        Integer first1 = list.getFirst();
+        //没有删除一直获取第一个
+        System.out.println(first1);
+        Integer remove1 = list.remove();
+        Integer remove2 = list.remove();
+        Integer remove3 = list.remove();
+
+        System.out.println(remove1);
+        System.out.println(remove2);
+        System.out.println(remove3);
+
+        System.out.println(list);
+
+    }
+
+
+}

+ 120 - 0
JavaSE/day19/src/com/lovecoding/day19/list01/TestList.java

@@ -0,0 +1,120 @@
+package com.lovecoding.day19.list01;
+
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class TestList {
+
+    /*
+    1、添加元素
+    * void add(int index, E ele)
+    * boolean addAll(int index, Collection<? extends E> eles)
+    2、获取元素
+    * E get(int index)
+    * List subList(int fromIndex, int toIndex)
+    3、获取元素索引
+    * int indexOf(Object obj)
+    * int lastIndexOf(Object obj)
+    4、删除和替换元素
+    * E remove(int index)
+    * E set(int index, E ele)
+     */
+
+    //E set(int index, E ele)
+    //E remove(int index)
+    @Test
+    public void test06(){
+        List<Integer> list = List.of(1, 2, 3, 4, 5, 5, 6, 7); //不可变
+        //构造方法
+        ArrayList<Integer> integers = new ArrayList<>(list);
+
+        integers.remove(1);
+
+        System.out.println(integers);
+        //修改 替换
+        Integer set = integers.set(0, 0);
+        System.out.println(set);
+
+        System.out.println(integers);
+
+    }
+
+
+    //int indexOf(Object obj)
+    //int lastIndexOf(Object obj)
+    @Test
+    public void test05(){
+        List<Integer> list = List.of(1, 2, 3, 4, 5, 5, 6, 7); //不可变
+        //boolean add = list.add(1);
+
+        int i = list.indexOf(5);
+
+        int i1 = list.lastIndexOf(5);
+        System.out.println(i);
+        System.out.println(i1);
+    }
+
+
+    //List subList(int fromIndex, int toIndex)
+    @Test
+    public void test04(){
+        List<String> list= new ArrayList<>();
+        list.add("1");
+        list.add("2");
+        list.add("3");
+
+        List<String> list1 = list.subList(0, 1);
+        System.out.println(list1);
+    }
+    //E get(int index)
+    @Test
+    public void test03(){
+        List<String> list= new ArrayList<>();
+        list.add("1");
+        list.add("2");
+        list.add("3");
+
+        System.out.println(list.get(0));
+        System.out.println(list.get(1));
+        System.out.println(list.get(2));
+        //System.out.println(list.get(3));
+
+        for (int i = 0; i < list.size(); i++) {
+            System.out.println(list.get(i));
+        }
+    }
+
+
+
+    //boolean addAll(int index, Collection<? extends E> eles)
+    @Test
+    public void test02(){
+        List<String> list1= new ArrayList<>();
+        list1.add("1");
+        list1.add("2");
+        list1.add("3");
+        List<String> list = List.of("3", "4", "5");
+        List<String> list2= new ArrayList<>(list);
+
+        boolean b = list1.addAll(list2);
+
+        System.out.println(list1);
+
+    }
+
+    //void add(int index, E ele)
+    @Test
+    public void test01(){
+        List<Integer> list = new ArrayList<>();
+
+        list.add(1);
+        list.add(1,2);
+        list.add(2,3);
+        //不能有间断 连续的 索引添加
+        //list.add(4,4);
+
+        System.out.println(list);
+    }
+}

+ 46 - 0
JavaSE/day19/src/com/lovecoding/day19/list01/TestListIterator.java

@@ -0,0 +1,46 @@
+package com.lovecoding.day19.list01;
+
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.ListIterator;
+
+public class TestListIterator {
+
+   /*
+    `boolean``hasNext()`如果此列表迭代器在向前遍历列表时具有更多元素,则返回 `true` 。
+    `E``next()`返回列表中的下一个元素并前进光标位置。
+    `int``nextIndex()`返回后续调用 [`next()`](#next())将返回的元素的索引。
+    `void``set(E e)`用指定的元素替换 [`next()`](#next())或 [`previous()`](#previous())返回的最后一个元素(可选操作)。
+    */
+
+    @Test
+    public void test01(){
+        List<Integer> list = new ArrayList<>(List.of(1, 2, 3, 4, 5));
+
+        //获取迭代器
+        ListIterator<Integer> listIterator = list.listIterator();
+
+        //boolean``hasNext()`如果此列表迭代器在向前遍历列表时具有更多元素,则返回 `true` 。
+        while (listIterator.hasNext()){
+            int i1 = listIterator.nextIndex();
+            System.out.println(i1);
+            //E``next()`返回列表中的下一个元素并前进光标位置。
+            Integer next = listIterator.next();
+
+            System.out.println("值:"+ next);
+            //nextIndex
+            int i2 = listIterator.nextIndex();
+            System.out.println(i2);
+
+            //set
+            if (next==2){
+                listIterator.set(11);
+            }
+
+        }
+
+        System.out.println(list);
+    }
+}

+ 24 - 0
JavaSE/day19/src/com/lovecoding/day19/list01/TestStack.java

@@ -0,0 +1,24 @@
+package com.lovecoding.day19.list01;
+
+import org.junit.Test;
+
+import java.util.Stack;
+
+public class TestStack {
+
+    @Test
+    public void test01(){
+
+        Stack<Integer> stack = new Stack<>();
+
+        stack.push(1);
+        stack.push(2);
+        stack.push(3);
+        stack.push(4);
+
+        Integer pop = stack.pop();
+        System.out.println(pop);
+
+
+    }
+}

+ 25 - 0
JavaSE/day19/src/com/lovecoding/day19/list01/TestVector.java

@@ -0,0 +1,25 @@
+package com.lovecoding.day19.list01;
+
+import org.junit.Test;
+
+import java.util.Iterator;
+import java.util.Vector;
+
+public class TestVector {
+
+    @Test
+    public void test01(){
+
+        Vector<Integer>  vector = new Vector<>();
+        vector.add(1);
+        vector.add(2);
+        vector.add(3);
+
+        Iterator<Integer> iterator = vector.iterator();
+
+        while (iterator.hasNext()){
+            System.out.println(iterator.next());
+        }
+
+    }
+}

+ 128 - 0
JavaSE/day19/src/com/lovecoding/day19/map01/TestMap01.java

@@ -0,0 +1,128 @@
+package com.lovecoding.day19.map01;
+
+import org.junit.Test;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+public class TestMap01 {
+    // 4、元视图操作的方法:
+
+    //* Set<K> keySet()
+    //* Collection<V> values()
+    //* Set<Map.Entry<K,V>> entrySet()
+    @Test
+    public void test04() {
+        Map<Integer, String> map = new HashMap<>();
+        //key 不重复   value 可以重复
+        map.put(1, "张三");
+        map.put(2, "李四");
+        map.put(3, "王五");
+
+        //遍历
+        Set<Integer> integers = map.keySet();
+
+        for (Integer integer : integers) {
+            String v = map.get(integer);
+            System.out.println("k:"+integer+"-v:"+v);
+        }
+
+        //values
+        Collection<String> values = map.values();
+        for (String value : values) {
+            System.out.println(value);
+        }
+
+        // entrySet()
+        for (Map.Entry<Integer, String> entry : map.entrySet()) {
+            Integer key = entry.getKey();
+            String value = entry.getValue();
+            System.out.println(key+"-"+value);
+        }
+
+
+        System.out.println(map.size());
+
+    }
+
+
+
+    // 3、元素查询的操作
+    //* V get(Object key)
+    //* boolean containsKey(Object key)
+    //* boolean containsValue(Object value)
+    //* boolean isEmpty()
+    @Test
+    public void test03() {
+
+        Map<Integer, String> map = new HashMap<>();
+        //key 不重复   value 可以重复
+        map.put(1, "张三");
+        map.put(2, "李四");
+        map.put(3, "王五");
+
+        String s = map.get(1);
+        System.out.println(s);
+
+        String s1 = map.get(2);
+        System.out.println(s1);
+        //删除
+        map.clear();
+        boolean b = map.containsKey(1);
+        System.out.println(b);
+
+        boolean ww = map.containsValue("王五");
+        System.out.println(ww);
+
+        System.out.println(map.isEmpty());
+    }
+
+
+    //2、删除
+    //* void clear()
+    //* V remove(Object key)
+    @Test
+    public void test02() {
+
+        Map<Integer, String> map = new HashMap<>();
+        //key 不重复   value 可以重复
+        map.put(1, "张三");
+        map.put(2, "张三");
+        map.put(3, "张三");
+
+
+        String remove = map.remove(1);
+        System.out.println(remove);
+
+        map.clear();
+        System.out.println(map);
+    }
+
+    //1、添加操作
+    //* V put(K key,V value)
+    //* void putAll(Map<? extends K,? extends V> m)
+    @Test
+    public void test01(){
+
+        Map<Integer,String> map = new HashMap<>();
+        //key 不重复   value 可以重复
+        map.put(1,"张三");
+        map.put(2,"张三");
+        map.put(3,"张三");
+
+        Map<Integer,String> map1 = new HashMap<>();
+        //key 不重复   value 可以重复
+        map1.put(1,"李四");
+        map1.put(2,"李四");
+        map1.put(4,"李四");
+
+        //添加 相同key 不重复 ,value 替换 之后的值会替换之前的值
+        map.putAll(map1);
+
+        System.out.println(map);
+    }
+
+
+}

+ 41 - 0
JavaSE/day19/src/com/lovecoding/day19/set01/Person.java

@@ -0,0 +1,41 @@
+package com.lovecoding.day19.set01;
+
+public class Person implements Comparable<Person> {
+    private String name;
+    private Integer age;
+
+    public Person(String name, Integer age) {
+        this.name = name;
+        this.age = age;
+    }
+
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public Integer getAge() {
+        return age;
+    }
+
+    public void setAge(Integer age) {
+        this.age = age;
+    }
+
+    @Override
+    public String toString() {
+        return "Person{" +
+                "name='" + name + '\'' +
+                ", age=" + age +
+                '}';
+    }
+
+    @Override
+    public int compareTo(Person o) {
+        return -o.name.compareTo(this.name);
+    }
+}

+ 22 - 0
JavaSE/day19/src/com/lovecoding/day19/set01/TestLinkedHashSet.java

@@ -0,0 +1,22 @@
+package com.lovecoding.day19.set01;
+
+import org.junit.Test;
+
+import java.util.LinkedHashSet;
+
+public class TestLinkedHashSet {
+
+    @Test
+    public void test01(){
+
+        LinkedHashSet<Integer> linkedHashSet = new LinkedHashSet<>();
+
+        linkedHashSet.add(1);
+        linkedHashSet.add(2);
+        linkedHashSet.add(3);
+        linkedHashSet.add(null);
+
+        System.out.println(linkedHashSet);
+
+    }
+}

+ 24 - 0
JavaSE/day19/src/com/lovecoding/day19/set01/TestSet.java

@@ -0,0 +1,24 @@
+package com.lovecoding.day19.set01;
+
+import org.junit.Test;
+
+import java.util.HashSet;
+import java.util.Set;
+
+public class TestSet {
+
+    @Test
+    public void test01(){
+
+        Set<Integer> set = new HashSet<>();
+
+        set.add(1);
+        set.add(2);
+        set.add(2);
+        set.add(3);
+        set.add(null);
+
+        System.out.println(set);
+
+    }
+}

+ 84 - 0
JavaSE/day19/src/com/lovecoding/day19/set01/TestTreeSet.java

@@ -0,0 +1,84 @@
+package com.lovecoding.day19.set01;
+
+import org.junit.Test;
+
+import java.util.Comparator;
+import java.util.TreeSet;
+
+public class  TestTreeSet {
+
+    //自定义类型排序 //自定义排序
+    @Test
+    public void test04(){
+        //自定义排序 排序规则
+        // public TreeSet(Comparator<? super E> comparator) {
+        //     this(new TreeMap<>(comparator));
+        // }
+        TreeSet<Person> set= new TreeSet<>(new Comparator<Person>() {
+            @Override
+            public int compare(Person o1, Person o2) {
+                return o1.getAge().compareTo(o2.getAge());
+            }
+        });
+
+        set.add(new Person("a",11));
+        set.add(new Person("b",12));
+        set.add(new Person("c",13));
+        set.add(new Person("d",14));
+
+
+        System.out.println(set);
+    }
+
+    //自定义类型排序 自然排序
+    @Test
+    public void test03(){
+        TreeSet<Person> set= new TreeSet<>();
+
+        set.add(new Person("a",11));
+        set.add(new Person("b",11));
+        set.add(new Person("c",11));
+        set.add(new Person("d",11));
+
+        //包装 TreeSet 数据必须实现 Comparable
+        System.out.println(set);
+
+    }
+
+
+    @Test
+    public void test02(){
+
+        TreeSet<Integer> treeSet1= new TreeSet<>();
+
+        treeSet1.add(1);
+        treeSet1.add(3);
+        treeSet1.add(9);
+        treeSet1.add(2);
+        treeSet1.add(6);
+        treeSet1.add(6);
+        //排序
+        // 自然排序  : 实现Comable 接口  泛型实现接口
+        // public int compareTo(Integer anotherInteger) {
+        //    return compare(this.value, anotherInteger.value);
+        // }
+        System.out.println(treeSet1);
+
+    }
+
+    @Test
+    public void test01(){
+
+        TreeSet<Integer> treeSet1= new TreeSet<>();
+
+        treeSet1.add(1);
+        treeSet1.add(3);
+        treeSet1.add(9);
+        treeSet1.add(2);
+        treeSet1.add(6);
+        treeSet1.add(6); //无重复
+        //排序
+        System.out.println(treeSet1);
+
+    }
+}

BIN
JavaSE/out/production/day17/com/lovecoding/day17/api/TestString.class


BIN
JavaSE/out/production/day17/com/lovecoding/day17/api/TestStringBuffer.class


BIN
JavaSE/out/production/day17/com/lovecoding/day17/ex01/Test01.class


BIN
JavaSE/out/production/day17/com/lovecoding/day17/ex01/Test02.class


BIN
JavaSE/out/production/day17/com/lovecoding/day17/ex01/Test03.class


BIN
JavaSE/out/production/day18/com/lovecoding/day18/MyArray.class


BIN
JavaSE/out/production/day18/com/lovecoding/day18/coll01/TestCollection01.class


BIN
JavaSE/out/production/day18/com/lovecoding/day18/ex01/Student.class


BIN
JavaSE/out/production/day18/com/lovecoding/day18/ex01/TestStudent$1.class


BIN
JavaSE/out/production/day18/com/lovecoding/day18/ex01/TestStudent.class


BIN
JavaSE/out/production/day18/com/lovecoding/day18/ex02/Employee.class


BIN
JavaSE/out/production/day18/com/lovecoding/day18/ex02/EmployeeAgeComparator.class


BIN
JavaSE/out/production/day18/com/lovecoding/day18/ex02/TestEmployee$1.class


BIN
JavaSE/out/production/day18/com/lovecoding/day18/ex02/TestEmployee.class


BIN
JavaSE/out/production/day18/com/lovecoding/day18/ex03/Coordinate.class


BIN
JavaSE/out/production/day18/com/lovecoding/day18/ex03/TestCoordinate.class


BIN
JavaSE/out/production/day18/com/lovecoding/day18/fanxing01/Student.class


BIN
JavaSE/out/production/day18/com/lovecoding/day18/fanxing01/TestFanXing.class


BIN
JavaSE/out/production/day18/com/lovecoding/day18/iterator01/TestIterator.class


BIN
JavaSE/out/production/day18/com/lovecoding/day18/iterator01/TestIterator2.class


BIN
JavaSE/out/production/day19/com/lovecoding/day19/ex01/Test01.class


BIN
JavaSE/out/production/day19/com/lovecoding/day19/ex02/TestStudent.class


BIN
JavaSE/out/production/day19/com/lovecoding/day19/list01/TestLinkedList.class


BIN
JavaSE/out/production/day19/com/lovecoding/day19/list01/TestList.class


BIN
JavaSE/out/production/day19/com/lovecoding/day19/list01/TestListIterator.class


BIN
JavaSE/out/production/day19/com/lovecoding/day19/list01/TestStack.class


BIN
JavaSE/out/production/day19/com/lovecoding/day19/list01/TestVector.class


BIN
JavaSE/out/production/day19/com/lovecoding/day19/map01/TestMap01.class


BIN
JavaSE/out/production/day19/com/lovecoding/day19/set01/Person.class


BIN
JavaSE/out/production/day19/com/lovecoding/day19/set01/TestLinkedHashSet.class


BIN
JavaSE/out/production/day19/com/lovecoding/day19/set01/TestSet.class


BIN
JavaSE/out/production/day19/com/lovecoding/day19/set01/TestTreeSet$1.class


BIN
JavaSE/out/production/day19/com/lovecoding/day19/set01/TestTreeSet.class