fjl123 9 місяців тому
батько
коміт
dace91d65e
31 змінених файлів з 994 додано та 0 видалено
  1. 10 0
      src/main/java/com/sf/day13/_01_final/Son.java
  2. 13 0
      src/main/java/com/sf/day13/_01_final/SuperClz.java
  3. 22 0
      src/main/java/com/sf/day13/_01_final/Test.java
  4. 14 0
      src/main/java/com/sf/day13/_01_final/WeekProperties.java
  5. 14 0
      src/main/java/com/sf/day13/_02_code_block/able/ILoginAble.java
  6. 19 0
      src/main/java/com/sf/day13/_02_code_block/able/impl/LoginAbleImpl.java
  7. 28 0
      src/main/java/com/sf/day13/_02_code_block/dt/Student.java
  8. 14 0
      src/main/java/com/sf/day13/_02_code_block/dt/User.java
  9. 49 0
      src/main/java/com/sf/day13/_02_code_block/test/Test.java
  10. 11 0
      src/main/java/com/sf/day13/_03_insert_class/able/IRunable.java
  11. 13 0
      src/main/java/com/sf/day13/_03_insert_class/dt/Anmail.java
  12. 72 0
      src/main/java/com/sf/day13/_03_insert_class/dt/Car.java
  13. 29 0
      src/main/java/com/sf/day13/_03_insert_class/dt/Outer.java
  14. 42 0
      src/main/java/com/sf/day13/_03_insert_class/test/Test.java
  15. 70 0
      src/main/java/com/sf/day13/_03_insert_class/test/Test1.java
  16. 27 0
      src/main/java/com/sf/day13/_04_enum/Gener.java
  17. 26 0
      src/main/java/com/sf/day13/_04_enum/PrefixSuffuxEnum.java
  18. 33 0
      src/main/java/com/sf/day13/_04_enum/Test.java
  19. 14 0
      src/main/java/com/sf/day13/_05_always_class/Test.java
  20. 12 0
      src/main/java/com/sf/day14/_01_package/able/IFunAble.java
  21. 24 0
      src/main/java/com/sf/day14/_01_package/able/impl/FunAbleImpl.java
  22. 30 0
      src/main/java/com/sf/day14/_01_package/dt/Student.java
  23. 45 0
      src/main/java/com/sf/day14/_01_package/test/Test.java
  24. 30 0
      src/main/java/com/sf/day14/_01_package/test/Test1.java
  25. 61 0
      src/main/java/com/sf/day14/_02_bigdecimal/test/Test.java
  26. 42 0
      src/main/java/com/sf/day14/_02_bigdecimal/test/Test1.java
  27. 23 0
      src/main/java/com/sf/day14/_02_bigdecimal/util/OperationUtil.java
  28. 29 0
      src/main/java/com/sf/day14/_03_string/test/Test.java
  29. 57 0
      src/main/java/com/sf/day14/_03_string/test/TestStringApi.java
  30. 81 0
      src/main/java/com/sf/day14/_03_string/test/TestStringContact.java
  31. 40 0
      src/main/java/com/sf/day14/_04_stringBuild/Test.java

+ 10 - 0
src/main/java/com/sf/day13/_01_final/Son.java

@@ -0,0 +1,10 @@
+package com.sf.day13._01_final;
+
+/**
+ * create By  fjl
+ */
+public class Son extends SuperClz {
+
+
+
+}

+ 13 - 0
src/main/java/com/sf/day13/_01_final/SuperClz.java

@@ -0,0 +1,13 @@
+package com.sf.day13._01_final;
+
+/**
+ * create By  fjl
+ */
+public  class SuperClz {
+
+    public static final int a = 10;
+
+    public final void eat(){
+        System.out.println("吃东西");
+    }
+}

+ 22 - 0
src/main/java/com/sf/day13/_01_final/Test.java

@@ -0,0 +1,22 @@
+package com.sf.day13._01_final;
+
+import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;
+
+/**
+ * create By  fjl
+ */
+public class Test {
+
+    public static void main(String[] args) {
+        // 如何拿到定义静态变量
+        System.out.println(SuperClz.a);
+//        SuperClz.a = 20;
+
+        /**
+         * 以后再实际开发当中会有一些常量类, 这些常量不允许修改的,而且值是固定有限
+         * 比如 星期一到星期日
+         * 需求: 定义一个常量类 星期一 值1 以此类推星期日是 7  ,后面调用的时候要用类名调用这些常量.
+         */
+        System.out.println(WeekProperties.MONDAY_VALUE);
+    }
+}

+ 14 - 0
src/main/java/com/sf/day13/_01_final/WeekProperties.java

@@ -0,0 +1,14 @@
+package com.sf.day13._01_final;
+
+/**
+ * create By  fjl
+ */
+public class WeekProperties {
+    public static final int MONDAY_VALUE = 0;
+    public static final int TUESDAY_VALUE = 1;
+    public static final int WEDNESDAY_VALUE = 2;
+//    public static final int MONDAY_VALUE = 0;
+//    public static final int MONDAY_VALUE = 0;
+//    public static final int MONDAY_VALUE = 0;
+//    public static final int MONDAY_VALUE = 0;
+}

+ 14 - 0
src/main/java/com/sf/day13/_02_code_block/able/ILoginAble.java

@@ -0,0 +1,14 @@
+package com.sf.day13._02_code_block.able;
+
+/**
+ * create By  fjl
+ */
+public interface ILoginAble {
+
+    /**
+     * 登录方法
+     * @param username
+     * @param password
+     */
+    void login(String username,String password);
+}

+ 19 - 0
src/main/java/com/sf/day13/_02_code_block/able/impl/LoginAbleImpl.java

@@ -0,0 +1,19 @@
+package com.sf.day13._02_code_block.able.impl;
+
+import com.sf.day13._02_code_block.able.ILoginAble;
+import com.sf.day13._02_code_block.dt.User;
+
+/**
+ * create By  fjl
+ */
+public class LoginAbleImpl implements ILoginAble {
+
+    @Override
+    public void login(String username, String password) {
+        if(username.equals(User.username) && password.equals(User.password)){
+            System.out.println("登录成功");
+        }else{
+            System.out.println("登录失败");
+        }
+    }
+}

+ 28 - 0
src/main/java/com/sf/day13/_02_code_block/dt/Student.java

@@ -0,0 +1,28 @@
+package com.sf.day13._02_code_block.dt;
+
+/**
+ * create By  fjl
+ */
+public class Student {
+
+    /**
+     * 定义一个初始化代码块
+     * 每次创建对象的时候都会调用初始化代码块
+     * 以后这个初始化代码块我们基本上是不用的, 因为就算做一些初始化的操作也是在构造器当中完成
+     */
+    {
+        System.out.println("调用了初始化代码块");
+    }
+
+    /**
+     * 创建一个静态代码块
+     * 静态代码块只是在你字节码加载到jvm当中的时候执行一次
+     */
+    static {
+        System.out.println("加载配置文件 静态代码块");
+    }
+
+    public Student(){
+        System.out.println("调用了无参数构造器");
+    }
+}

+ 14 - 0
src/main/java/com/sf/day13/_02_code_block/dt/User.java

@@ -0,0 +1,14 @@
+package com.sf.day13._02_code_block.dt;
+
+/**
+ * create By  fjl
+ */
+public class User {
+    public static String username;
+    public static String password;
+
+    static {
+        username = "admin";
+        password = "123";
+    }
+}

+ 49 - 0
src/main/java/com/sf/day13/_02_code_block/test/Test.java

@@ -0,0 +1,49 @@
+package com.sf.day13._02_code_block.test;
+
+import com.sf.day13._02_code_block.able.ILoginAble;
+import com.sf.day13._02_code_block.able.impl.LoginAbleImpl;
+import com.sf.day13._02_code_block.dt.Student;
+
+import java.util.Scanner;
+
+/**
+ * create By  fjl
+ */
+public class Test {
+
+    public static void main(String[] args) {
+        // 局部代码块
+        // 局部是定义在方法当中
+        {
+            int a  = 10;
+            System.out.println(a);
+        }
+        // 问在代码块外面可否打印a
+        // 不可以: 因为他范围只是在代码块内部可以使用
+        // 局部代码块一般不会这样使用
+        // 局部代码块一般不会单独使用, 一般配合for while
+//        for (int i = 0; i < 10; i++) {
+//            System.out.println(i);
+//        }
+        Student student = new Student();
+        Student student1 = new Student();
+
+
+        /**
+         * 定义一个账户类User , 要求账户类要有username和password
+         * 要求在类加载的时候给username=admin 密码password=123
+         *
+         * 完成登录: 面向接口编程
+         * 在控制台当中输入账号 和输入密码 , 调用接口login 方法
+         * login 方法判断账号登admin 密码等于123 表示登录成功,否则登录失败
+         */
+        Scanner scanner = new Scanner(System.in);
+        System.out.println("请输入账号:");
+        String username = scanner.next();
+        System.out.println("请输入密码:");
+        String password = scanner.next();
+        // 调用接口当中
+        ILoginAble loginAble = new LoginAbleImpl();
+        loginAble.login(username,password);
+    }
+}

+ 11 - 0
src/main/java/com/sf/day13/_03_insert_class/able/IRunable.java

@@ -0,0 +1,11 @@
+package com.sf.day13._03_insert_class.able;
+
+/**
+ * create By  fjl
+ */
+public interface IRunable {
+    /**
+     * 运行方法
+     */
+    void run();
+}

+ 13 - 0
src/main/java/com/sf/day13/_03_insert_class/dt/Anmail.java

@@ -0,0 +1,13 @@
+package com.sf.day13._03_insert_class.dt;
+
+import com.sf.day13._03_insert_class.able.IRunable;
+
+/**
+ * create By  fjl
+ */
+public class Anmail {
+
+    public void runner(IRunable runable){
+        runable.run();
+    }
+}

+ 72 - 0
src/main/java/com/sf/day13/_03_insert_class/dt/Car.java

@@ -0,0 +1,72 @@
+package com.sf.day13._03_insert_class.dt;
+
+/**
+ * create By  fjl
+ */
+/**
+ * 需求: 定义一个Car 类 有brand ,color , 这个Car有一个发动机Engine color,brand , 方法 start
+ *
+ *  要求: 1 给发动机设置品牌只为 LS 400
+ *       2 给car的brand 设置只为 雷克萨斯,
+ *       3 在控制台当中打印出来骑车的品牌和发动机的品牌
+ *       4 调用发动机start方法, 在控制台打印启动了发动机
+ *
+ *
+ *
+ */
+public class Car  {
+    private String brand;
+    private String color;
+
+    public Car(String brand, String color) {
+        this.brand = brand;
+        this.color = color;
+    }
+
+    public class Engine{
+        private String color;
+        private String brand;
+
+        public Engine(String color, String brand) {
+            this.color = color;
+            this.brand = brand;
+        }
+
+        public String getColor() {
+            return color;
+        }
+
+        public void setColor(String color) {
+            this.color = color;
+        }
+
+        public String getBrand() {
+            return brand;
+        }
+
+        public void setBrand(String brand) {
+            this.brand = brand;
+        }
+
+        public void start(){
+            System.out.println("启动发动机");
+        }
+    }
+
+    public String getBrand() {
+        return brand;
+    }
+
+    public void setBrand(String brand) {
+        this.brand = brand;
+    }
+
+    public String getColor() {
+        return color;
+    }
+
+    public void setColor(String color) {
+        this.color = color;
+    }
+}
+

+ 29 - 0
src/main/java/com/sf/day13/_03_insert_class/dt/Outer.java

@@ -0,0 +1,29 @@
+package com.sf.day13._03_insert_class.dt;
+
+/**
+ * create By  fjl
+ */
+public class Outer {
+
+    /**
+     * 定义成员内部类
+     * 和之前成员变量很相似
+     * private public default procted
+     *
+     */
+    public class Inner{
+        public void item(){
+            System.out.println("这是内部类当中方法");
+        }
+    }
+
+    /**
+     * 定义静态内部类
+     */
+    public static class Inner1{
+        public void item(){
+            System.out.println("这是内部类当中方法");
+        }
+    }
+
+}

+ 42 - 0
src/main/java/com/sf/day13/_03_insert_class/test/Test.java

@@ -0,0 +1,42 @@
+package com.sf.day13._03_insert_class.test;
+
+import com.sf.day13._03_insert_class.dt.Car;
+import com.sf.day13._03_insert_class.dt.Outer;
+
+/**
+ * create By  fjl
+ */
+public class Test {
+
+    public static void main(String[] args) {
+//        外部类.内部类 变量 = new 外部类().new 内部类();
+        /**
+         * 要求调用内部类当中item 方法
+         */
+//        Outer.Inner inner =  new Outer().new Inner();
+//        inner.item();
+
+        /**
+         * 需求: 定义一个Car 类 有brand ,color , 这个Car有一个发动机Engine color,brand , 方法 start
+         *
+         *  要求: 1 给发动机设置品牌只为 LS 400
+         *       2 给car的brand 设置只为 雷克萨斯,
+         *       3 在控制台当中打印出来骑车的品牌和发动机的品牌
+         *       4 调用发动机start方法, 在控制台打印启动了发动机
+         *
+         *
+         *
+         */
+//        Car car = new Car("雷克萨斯","白色");
+//        Car.Engine engine = car.new Engine("银白色","LS 400");
+//        System.out.println(engine.getBrand());
+//        System.out.println(car.getBrand());
+//        engine.start();
+
+
+//        外部类.内部类  变量 = new  外部类.内部类构造器;
+        Outer.Inner1 inner1 = new Outer.Inner1();
+        inner1.item();
+
+    }
+}

+ 70 - 0
src/main/java/com/sf/day13/_03_insert_class/test/Test1.java

@@ -0,0 +1,70 @@
+package com.sf.day13._03_insert_class.test;
+
+import com.sf.day13._03_insert_class.able.IRunable;
+import com.sf.day13._03_insert_class.dt.Anmail;
+
+/**
+ * create By  fjl
+ */
+public class Test1 {
+
+    public static void main(String[] args) {
+        // 匿名内部类的写法
+        // 前面是接口或者是父类
+//        new IRunable() {
+//            @Override
+//            public void run() {
+//
+//            }
+//        };
+        /**
+         * 上面代码就相当于给我们runable 接口创建一个实现类 ,没有名字
+         */
+        /**
+         * 对比那种更加简单
+         * 没有匿名内部类之前
+         * 创建接口 -> 创建实现类实现接口 -> 测试
+         * 有了匿名内部类
+         * 创建接口 -> 测试
+         *
+         */
+//        IRunable runable = new IRunable() {
+//            @Override
+//            public void run() {
+//                System.out.println("运行");
+//            }
+//        };
+//        runable.run();
+
+        /**
+         * 定义一个接口IRunAble,定义run 方法
+         *
+         * 定义Anmail 的类, 这个类当中需要有一个方法
+         * public void runner(IRunAble able){
+         *     able.run()
+         * }
+         *
+         * 后学测试时候, 需要分两次调用runner 的方法, 第一次要打印狗跑步,第二次要打印猫跑步 ,注意使用匿名内部了方式
+         */
+
+        Anmail anmail = new Anmail();
+        anmail.runner(new IRunable() {
+            @Override
+            public void run() {
+                System.out.println("狗跑步");
+            }
+        });
+        anmail.runner(new IRunable() {
+            @Override
+            public void run() {
+                System.out.println("猫跑步");
+            }
+        });
+
+
+
+
+
+
+    }
+}

+ 27 - 0
src/main/java/com/sf/day13/_04_enum/Gener.java

@@ -0,0 +1,27 @@
+package com.sf.day13._04_enum;
+
+/**
+ * create By  fjl
+ */
+public enum Gener {
+    //WOMAN => Gener()  WOMAN("type") = Gener("type")
+    // jdk1.5 之前
+    // 定义颜色常量
+//    public static final Gener MAN = new Gener("type");
+//    public static final Gener WOMAN = new Gener("type1");
+
+    WOMAN("type1"),MAN("type2");
+
+    private String type;
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    Gener(String type) {
+        this.type = type;
+    }}

+ 26 - 0
src/main/java/com/sf/day13/_04_enum/PrefixSuffuxEnum.java

@@ -0,0 +1,26 @@
+package com.sf.day13._04_enum;
+
+/**
+ * create By  fjl
+ */
+public enum PrefixSuffuxEnum {
+    P1("prefix1","suffux1"),P2("prefix2","suffux2");
+
+    private String prefix;
+    private String suffux;
+
+    PrefixSuffuxEnum(String prefix, String suffux) {
+        this.prefix = prefix;
+        this.suffux = suffux;
+    }
+
+    /**
+     * 定义方法: prefix + "_" + suffux
+     */
+    public String join(){
+        return this.prefix + "_" + this.suffux;
+    }
+
+}
+
+

+ 33 - 0
src/main/java/com/sf/day13/_04_enum/Test.java

@@ -0,0 +1,33 @@
+package com.sf.day13._04_enum;
+
+/**
+ * create By  fjl
+ */
+public class Test {
+
+    public static void main(String[] args) {
+        // 获取到枚举当中WOMAN
+        // 返回值其实就是我们的枚举对象
+//        Gener gener = Gener.WOMAN;
+//        // 正常Gener 对象 打印应该看到一个地址值
+//        // 实际看到的定义变量名字, 说明枚举重写了Object当中toString() 方法
+//        System.out.println(gener.getType());
+
+        /**
+         * 枚举练习:
+         * 定义一个枚举类有两个字段,一个是前prefix ,一个是后suffux
+         * 枚举中有两个常量 第一个前 prefix1 后 suffux1
+         *               第二个前 prefix2 后 suffux2
+         *
+         * 枚举当中定义方法返回前缀 + 后缀  比如prefix1 suffux1  返回 prefix1 +"_" + suffux1
+         *
+         */
+        PrefixSuffuxEnum p1 = PrefixSuffuxEnum.P1;
+        PrefixSuffuxEnum p2 = PrefixSuffuxEnum.P2;
+        // prefix1_suffux1
+        System.out.println(p1.join());
+        // prefix2_suffux2
+        System.out.println(p2.join());
+
+    }
+}

+ 14 - 0
src/main/java/com/sf/day13/_05_always_class/Test.java

@@ -0,0 +1,14 @@
+package com.sf.day13._05_always_class;
+
+import java.util.Arrays;
+
+/**
+ * create By  fjl
+ */
+public class Test {
+    public static void main(String[] args) {
+        int[] arr = {3,4,5,1,8,7};
+        Arrays.sort(arr);
+        System.out.println(Arrays.toString(arr));
+    }
+}

+ 12 - 0
src/main/java/com/sf/day14/_01_package/able/IFunAble.java

@@ -0,0 +1,12 @@
+package com.sf.day14._01_package.able;
+
+/**
+ * create By  fjl
+ */
+public interface IFunAble {
+
+    /**
+     * 保存学生方法
+     */
+    void save(String name,Integer age);
+}

+ 24 - 0
src/main/java/com/sf/day14/_01_package/able/impl/FunAbleImpl.java

@@ -0,0 +1,24 @@
+package com.sf.day14._01_package.able.impl;
+
+import com.sf.day14._01_package.able.IFunAble;
+import com.sf.day14._01_package.dt.Student;
+
+/**
+ * create By  fjl
+ */
+public class FunAbleImpl implements IFunAble {
+
+    @Override
+    public void save(String name, Integer age) {
+        // 判断name 和 age 不能为空
+        // int 基本类型, 不是对象, 不能够判空
+        // 如何解决: 使用包装类型把基本来兴包装成一个Integer 对象
+        if(name==null && age==null){
+            System.out.println("name和age不能为空");
+        }
+        // 如果不为空的话把数据封装到Student对象当中
+        Student student = new Student(name,age);
+        // 在控制台当中打印
+        System.out.println(student);
+    }
+}

+ 30 - 0
src/main/java/com/sf/day14/_01_package/dt/Student.java

@@ -0,0 +1,30 @@
+package com.sf.day14._01_package.dt;
+
+/**
+ * create By  fjl
+ */
+public class Student {
+    private String name;
+    private int age;
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public int getAge() {
+        return age;
+    }
+
+    public void setAge(int age) {
+        this.age = age;
+    }
+
+    public Student(String name, int age) {
+        this.name = name;
+        this.age = age;
+    }
+}

+ 45 - 0
src/main/java/com/sf/day14/_01_package/test/Test.java

@@ -0,0 +1,45 @@
+package com.sf.day14._01_package.test;
+
+/**
+ * create By  fjl
+ */
+public class Test {
+
+    public static void main(String[] args) {
+        // 创建出来包装类
+        // 从文档中看到包装类是提供了构造方法, 说明可以通过new 方法
+//        Integer integer = new Integer(10);
+//        if(integer!=null){
+//            // 说明Integer 里面已经覆盖了Object当中toString()方法 打印integer int值
+//            System.out.println(integer);
+//            System.out.println("这是一个包装类型");
+//        }
+//
+//        // 方式2  Integer.valueOf(10)
+//        Integer integer1 = Integer.valueOf(11);
+//        System.out.println(integer1);
+
+        // 问题: 两者有什么区别?
+        // Integer.valueOf()   在去操作时候有一个缓存池范围是 -128 127
+        // 作用 如果第一个使用Integer.valueOf(10) 上缓存池中看是否有这个包装类,如果没有创建出来这个包装类
+        //     第二次在去使用Integer.valueof(10)  上缓存池当中看是否有包装类, 如果有直接用这个包装类了
+
+        //面试题,判断下面结果
+        Integer integer = new Integer(10);
+        Integer integer1 = new Integer(10);
+        System.out.println(integer == integer1);   //false
+        Integer integer2 = Integer.valueOf(10);
+        Integer integer3 = Integer.valueOf(10);
+        System.out.println(integer2==integer3);   //true
+        System.out.println(integer1==integer3);   //false
+        // 基本类型和包装类型转换
+        // 作为了解, 因为以后我们都是直接使用包装类
+        // 装箱: 基本类型转成包装类  拆箱: 包装类转成基本类型
+        // jjdk5当中提供的自动装箱和拆箱其实是一个语法糖
+        // 语法糖: 简化我们写代码 , 知道他本质磁层还是使用之前的方式
+        // 没有语法糖: new  Integer 或者是 Integer.valueOf
+        Integer i = 10;   //自动装箱  -> 装箱必须掌握
+        int i1 = i;       //自动拆箱
+
+    }
+}

+ 30 - 0
src/main/java/com/sf/day14/_01_package/test/Test1.java

@@ -0,0 +1,30 @@
+package com.sf.day14._01_package.test;
+
+import com.sf.day14._01_package.able.IFunAble;
+import com.sf.day14._01_package.able.impl.FunAbleImpl;
+
+import java.util.Scanner;
+
+/**
+ * create By  fjl
+ */
+public class Test1 {
+
+    public static void main(String[] args) {
+        // 把name 和age 在控制台输入, 调用接口当中方法进行保存
+        Scanner scanner = new Scanner(System.in);
+        System.out.println("请输入name:");
+        String name = scanner.next();
+        System.out.println("请输入age:");
+        String age = scanner.next();
+
+        IFunAble f = new FunAbleImpl();
+        // Integer 和String 之间的一个转换  Integer-> String  String->Integer
+        // Integer -> String  调用Integer.toString();
+        // String -> int      调用Integer.parseInt(String s)
+        int a = Integer.parseInt(age);
+        f.save(name,a);
+
+    }
+}
+

+ 61 - 0
src/main/java/com/sf/day14/_02_bigdecimal/test/Test.java

@@ -0,0 +1,61 @@
+package com.sf.day14._02_bigdecimal.test;
+
+import com.sf.day14._02_bigdecimal.util.OperationUtil;
+
+import java.math.BigDecimal;
+import java.util.Scanner;
+
+/**
+ * create By  fjl
+ */
+public class Test {
+    public static void main(String[] args) {
+        //需求: 计算0.09 + 0.01
+//        System.out.println(0.09+0.01);
+//        // 在java 当中使用double 或者是float 在去进行计算的时候精度是不准确
+//        // 解决: 常用类当中BigDecmail
+//        // 创建一个BigDecemail对象
+//        BigDecimal bigDecimal = new BigDecimal("10.00");
+//        BigDecimal bigDecimal1 = new BigDecimal("20.00");
+//        // 如果要对bigDecmail类型进行运算, 必须要调用当中方法
+//        // 分别定义加减乘除方法  add subtract multiply  divide
+//        System.out.println(bigDecimal.add(bigDecimal1));   // 30
+//        System.out.println(bigDecimal1.subtract(bigDecimal)); //10
+//        System.out.println(bigDecimal.multiply(bigDecimal1)); //200
+//        System.out.println(bigDecimal1.divide(bigDecimal));   //2
+
+        /**
+         * 需求: 在控制台分别输入3个内容  num  运算符  + - * /  num1
+         * 效果: 第一输入 1.3  第二次输入+  第三处输入 2.2  最终效果 1+2
+         *
+         * 额外要去使用swich 或者是if 都可以, 这些加减乘除操作
+         * 要单出抽取出来方法不可以写在main方法中
+         */
+        Scanner scanner = new Scanner(System.in);
+        System.out.println("请输入第一个值:");
+        String num = scanner.next();
+        System.out.println("请输入运算符:");
+        String ret = scanner.next();
+        System.out.println("请输入第二个值:");
+        String num2 = scanner.next();
+
+        BigDecimal v1 = new BigDecimal(num);
+        BigDecimal v2 = new BigDecimal(num2);
+
+        BigDecimal result = null;
+        if("+".equals(ret)){
+            result = OperationUtil.myAdd(v1, v2);
+        }else if("-".equals(ret)){
+            result = OperationUtil.mySubstract(v1, v2);
+        }else if("*".equals(ret)){
+            result = OperationUtil.myMultiply(v1, v2);
+        }else if("/".equals(ret)){
+            result = OperationUtil.myDivide(v1, v2);
+        }
+        System.out.println(result.toString());
+
+
+
+    }
+
+}

+ 42 - 0
src/main/java/com/sf/day14/_02_bigdecimal/test/Test1.java

@@ -0,0 +1,42 @@
+package com.sf.day14._02_bigdecimal.test;
+
+import java.math.BigDecimal;
+
+/**
+ * create By  fjl
+ */
+public class Test1 {
+    public static void main(String[] args) {
+        /**
+         * 需求: 已经有一个数组 ["188.2","199","177","200","100"]
+         * 要求计算出来总价格
+         * 如果总价格大于1000 打9折
+         * 如果总价格大于2000 打8折
+         * 如果总价格大于3000 打7折
+         *
+         * 最终计算打印出来最终打完折的价格
+         */
+        String[] arr = {"1881.2","199","177","200","100"};
+        BigDecimal total =new BigDecimal(0);
+
+        // 通过for 循环去遍历数组拿到每一个元素
+        for (int i = 0; i < arr.length; i++) {
+            BigDecimal item = new BigDecimal(arr[i]);
+            total = total.add(item);
+        }
+        System.out.println("没打折总价" +total.toString());
+        //判断总价如果大约1000 0.9 如果大于2000 0.8 如果是大于3000 0.7
+        double intVal = Double.parseDouble(total.toString());
+        BigDecimal result =  null;
+        if(intVal> 1000){
+            result = total.multiply(new BigDecimal("0.9"));
+        }else if(intVal>2000){
+            result = total.multiply(new BigDecimal("0.8"));
+        }else if(intVal>3000){
+            result = total.multiply(new BigDecimal("0.7"));
+        }
+        System.out.println("打折以后的"+ result.toString());
+
+
+    }
+}

+ 23 - 0
src/main/java/com/sf/day14/_02_bigdecimal/util/OperationUtil.java

@@ -0,0 +1,23 @@
+package com.sf.day14._02_bigdecimal.util;
+
+import java.math.BigDecimal;
+
+/**
+ * create By  fjl
+ */
+public class OperationUtil {
+    // 加法
+    public static BigDecimal myAdd(BigDecimal num,BigDecimal num1){
+        return num.add(num1);
+    }
+    public static BigDecimal mySubstract(BigDecimal num,BigDecimal num1){
+        return num.subtract(num1);
+    }
+    public static BigDecimal myMultiply(BigDecimal num,BigDecimal num1){
+        return num.multiply(num1);
+    }
+    public static BigDecimal myDivide(BigDecimal num,BigDecimal num1){
+        return num.divide(num1);
+    }
+
+}

+ 29 - 0
src/main/java/com/sf/day14/_03_string/test/Test.java

@@ -0,0 +1,29 @@
+package com.sf.day14._03_string.test;
+
+/**
+ * create By  fjl
+ */
+public class Test {
+
+    public static void main(String[] args) {
+        // 创建字符串两种方式
+        // 方式1: String 变量 = "值"
+        String name = "test Name";
+        String name4 = "test Name";
+        // 方式2: String 变量 = new String("值")
+        String name1 = new String("test Name");
+        String name2 = new String("test Name");
+
+        // 在面试中出现比较多
+        System.out.println(name == name4);
+        System.out.println(name1==name2);
+        System.out.println(name == name1);
+
+        // 在实际开发中我们很少去比较地址值, 比较实际值
+        // Object 当中有个方法equals 方法  , equals 默认比较的也是地址值
+        // 如果你要按照自己规则进行比较,需要重写equals 去进行比较
+        // 说明String 他重写Object 当中equals 方法
+        System.out.println(name.equals(name4));    //true
+        System.out.println(name.equals(name1));    //true
+    }
+}

+ 57 - 0
src/main/java/com/sf/day14/_03_string/test/TestStringApi.java

@@ -0,0 +1,57 @@
+package com.sf.day14._03_string.test;
+
+import java.util.Arrays;
+
+/**
+ * create By  fjl
+ */
+public class TestStringApi {
+    public static void main(String[] args) {
+        //字符串 底层就是字符数组 [A,B,C,D]
+        String str = "ABCDBCsdfdsfBC";
+        // int length() 返回此字符串的字符个数
+        System.out.println("字符个数:"+ str.length());
+        // char charAt(int index) 返回指定索引位置的字符
+        System.out.println("字符为:" + str.charAt(1));
+
+//        int indexOf(String str) 返回指定字符串str在此字符串中从左向右第一次出现处的索引位置
+        System.out.println("BC出现位置:" + str.indexOf("BC"));
+
+        // 第一次出现sd位置
+        System.out.println("sd出现位置:"+ str.indexOf("sd"));
+
+//        boolean endWith(String suffix)  判断是否是以某一个字符串开始
+//        boolean endWith(String suffix)  判断是否以某一个字符串结束
+        String str1 = "HELLO WORD";
+        String str2 = "hello word";
+        //判断是否是以HELLO 开头  以WORD 结束
+        System.out.println(str1.startsWith("HELLO"));
+        System.out.println(str1.endsWith("WORD"));
+        System.out.println(str1.equals(str));
+        System.out.println(str1.equals(str2));
+        System.out.println(str1.equalsIgnoreCase(str2));
+
+        String str3 = "Hello Word";
+        // String toUpperCase()  把当前字符串转换为大写
+        System.out.println(str3.toUpperCase());
+        // String toLowerCase()  把当前字符串转换为小写
+        System.out.println(str3.toLowerCase());
+
+        String str4 = "test123456";
+        // 需求截取字符串123456
+        System.out.println(str4.substring(4));
+        // 需求截取 st123    [2,7)   2,3,4,5,6
+        System.out.println(str4.substring(2,7));
+
+//        String replace(String oldStr,  String newStr)  替换
+        System.out.println(str4.replace("st","sb"));
+//        String trim() 返回一个字符串,其值为此字符串,并删除任何前导和尾随空格。
+        String str5 = "    hello word   ";
+        System.out.println(str5.trim());
+
+        String str6 = "A,B,C";
+        String[] arr = str6.split(",");
+        System.out.println(Arrays.toString(arr));
+
+    }
+}

+ 81 - 0
src/main/java/com/sf/day14/_03_string/test/TestStringContact.java

@@ -0,0 +1,81 @@
+package com.sf.day14._03_string.test;
+
+import sun.nio.ch.sctp.SctpNet;
+
+import java.util.Arrays;
+import java.util.Scanner;
+
+/**
+ * create By  fjl
+ */
+public class TestStringContact {
+
+    public static void main(String[] args) {
+        //练习1
+//        contact1();
+//        contact2();
+
+//      需求3: 有字符串str = hello,word,
+//      现要求在控制台打印2行内容出来
+//      第一行HELLO 第二行WORD
+        contact3();
+
+
+    }
+
+    private static void contact3() {
+        String str = "hello,word";
+        String[] arr = str.split(",");
+        for (int i = 0; i < arr.length; i++) {
+            String st = arr[i];
+            System.out.println(st.toUpperCase());
+        }
+    }
+
+    private static void contact2() {
+//        需求2: 在控制台当中输入字符串
+        Scanner scanner = new Scanner(System.in);
+        System.out.println("请输入内容:");
+        String str = scanner.next();
+//        判断字符串str中是否包含st ,
+//        通过indexOf 如果匹配到会返回索引位置, 如果匹配不到返回-1
+        if(str.indexOf("st")>=0){
+            // 如果包含就替换成sb
+            str = str.replace("st","sb");
+            System.out.println(str);
+        }
+
+
+    }
+
+    // 手机号码屏蔽
+    private static void contact1() {
+        Scanner scanner = new Scanner(System.in);
+        System.out.println("请输入手机号码:");
+        String phone = scanner.next();
+
+
+        // 如果手机号码长度不对我们要提醒用户手机号码格式不正确
+        // 要求手机号码必须符合我们现实生活中手机号
+        // 在字符串中某一个方法match() 写字符串匹配规则,匹配规则又叫做正则表达式
+        if(phone.length()!= 11){
+            System.out.println("手机号码格式不正确");
+            return;
+        }
+
+        String regex = "^1[3-9]\\d{9}$";
+        boolean flag = phone.matches(regex);
+        if(!flag){
+            System.out.println("手机号码无效");
+            return;
+        }
+
+        System.out.println("手机号码有效");
+        // 截取手机号码的前3位  和手机号码的后4位
+        //
+        // substring(0,3)  substring(7)
+        String str = phone.substring(0, 3);
+        String str1 = phone.substring(7);
+        System.out.println(str + "****" + str1);
+    }
+}

+ 40 - 0
src/main/java/com/sf/day14/_04_stringBuild/Test.java

@@ -0,0 +1,40 @@
+package com.sf.day14._04_stringBuild;
+
+/**
+ * create By  fjl
+ */
+public class Test {
+    public static void main(String[] args) {
+        // 创建Stringbuild 对象 , new StringBuild();
+        /**
+         * 面试题: String 和Stringbuild 区别
+         * String: 不可变的 因为他底层使用是final进行修饰 , StringBuild : 底层是可以变数据
+         */
+        StringBuilder sb = new StringBuilder();
+
+        // sb  length 长度  captcal 容量  append 追加
+//        System.out.println(sb.capacity());
+//        sb.append("abc").append("cedf");
+//
+//        System.out.println(sb.length());
+
+        // 需求现在有这样字符串  str = "1;2;3;4;5;7;8" ,
+        // 要求最后输出[1,2,3,4,5,7,8] 注: 这是一个字符串格式
+        String str = "1;2;3;4;5;6;7";
+        sb.append("[");
+        //按照; 进行分割
+        String[] arr = str.split(";");
+        for (int i = 0; i < arr.length; i++) {
+
+            if(i == arr.length-1){
+                sb.append(arr[i]);
+            }else{
+                sb.append(arr[i]).append(",");
+            }
+        }
+        sb.append("]");
+        System.out.println(sb);
+
+
+    }
+}