xerga 1 năm trước cách đây
mục cha
commit
7c19e40974
41 tập tin đã thay đổi với 357 bổ sung0 xóa
  1. 1 0
      JavaSe01/.idea/modules.xml
  2. 11 0
      JavaSe01/day12/src/com/lc/day12/test/Test.java
  3. 85 0
      JavaSe01/day12/src/com/lc/day12/test/TestInner.java
  4. 11 0
      JavaSe01/day13/day13.iml
  5. 27 0
      JavaSe01/day13/src/com/lc/day13/exer/Test.java
  6. 34 0
      JavaSe01/day13/src/com/lc/day13/exer/Test01.java
  7. 61 0
      JavaSe01/day13/src/com/lc/day13/inter01/Test01.java
  8. 17 0
      JavaSe01/day13/src/com/lc/day13/inter02/Audi.java
  9. 33 0
      JavaSe01/day13/src/com/lc/day13/inter02/CarInterface.java
  10. 23 0
      JavaSe01/day13/src/com/lc/day13/inter02/Test01.java
  11. 54 0
      JavaSe01/day13/src/com/lc/day13/inter03/Test.java
  12. BIN
      JavaSe01/out/production/day12/com/lc/day12/test/Outer$InnerClass.class
  13. BIN
      JavaSe01/out/production/day12/com/lc/day12/test/Outer$InnerClassAbs.class
  14. BIN
      JavaSe01/out/production/day12/com/lc/day12/test/Outer$InnerClassFinal.class
  15. BIN
      JavaSe01/out/production/day12/com/lc/day12/test/Outer$InnerStaticClass.class
  16. BIN
      JavaSe01/out/production/day12/com/lc/day12/test/Outer.class
  17. BIN
      JavaSe01/out/production/day12/com/lc/day12/test/Test.class
  18. BIN
      JavaSe01/out/production/day12/com/lc/day12/test/TestInner.class
  19. BIN
      JavaSe01/out/production/day13/com/lc/day13/exer/A.class
  20. BIN
      JavaSe01/out/production/day13/com/lc/day13/exer/B.class
  21. BIN
      JavaSe01/out/production/day13/com/lc/day13/exer/Ball.class
  22. BIN
      JavaSe01/out/production/day13/com/lc/day13/exer/C.class
  23. BIN
      JavaSe01/out/production/day13/com/lc/day13/exer/Play1Interface.class
  24. BIN
      JavaSe01/out/production/day13/com/lc/day13/exer/Play2Interface.class
  25. BIN
      JavaSe01/out/production/day13/com/lc/day13/exer/Test.class
  26. BIN
      JavaSe01/out/production/day13/com/lc/day13/exer/Test01.class
  27. BIN
      JavaSe01/out/production/day13/com/lc/day13/inter01/A.class
  28. BIN
      JavaSe01/out/production/day13/com/lc/day13/inter01/AA.class
  29. BIN
      JavaSe01/out/production/day13/com/lc/day13/inter01/AAA.class
  30. BIN
      JavaSe01/out/production/day13/com/lc/day13/inter01/B.class
  31. BIN
      JavaSe01/out/production/day13/com/lc/day13/inter01/C.class
  32. BIN
      JavaSe01/out/production/day13/com/lc/day13/inter01/Test01$1.class
  33. BIN
      JavaSe01/out/production/day13/com/lc/day13/inter01/Test01.class
  34. BIN
      JavaSe01/out/production/day13/com/lc/day13/inter02/Audi.class
  35. BIN
      JavaSe01/out/production/day13/com/lc/day13/inter02/CarInterface.class
  36. BIN
      JavaSe01/out/production/day13/com/lc/day13/inter02/Test01.class
  37. BIN
      JavaSe01/out/production/day13/com/lc/day13/inter03/A.class
  38. BIN
      JavaSe01/out/production/day13/com/lc/day13/inter03/AAA.class
  39. BIN
      JavaSe01/out/production/day13/com/lc/day13/inter03/B.class
  40. BIN
      JavaSe01/out/production/day13/com/lc/day13/inter03/C.class
  41. BIN
      JavaSe01/out/production/day13/com/lc/day13/inter03/Test.class

+ 1 - 0
JavaSe01/.idea/modules.xml

@@ -13,6 +13,7 @@
       <module fileurl="file://$PROJECT_DIR$/day10/day10.iml" filepath="$PROJECT_DIR$/day10/day10.iml" />
       <module fileurl="file://$PROJECT_DIR$/day11/day11.iml" filepath="$PROJECT_DIR$/day11/day11.iml" />
       <module fileurl="file://$PROJECT_DIR$/day12/day12.iml" filepath="$PROJECT_DIR$/day12/day12.iml" />
+      <module fileurl="file://$PROJECT_DIR$/day13/day13.iml" filepath="$PROJECT_DIR$/day13/day13.iml" />
     </modules>
   </component>
 </project>

+ 11 - 0
JavaSe01/day12/src/com/lc/day12/test/Test.java

@@ -0,0 +1,11 @@
+package com.lc.day12.test;
+
+/**
+ * ClassName: Test
+ *
+ * @Author 爱扣钉-陈晨
+ * @Create 2023/11/7 11:21
+ * @Version 1.0
+ */
+public class Test {
+}

+ 85 - 0
JavaSe01/day12/src/com/lc/day12/test/TestInner.java

@@ -0,0 +1,85 @@
+package com.lc.day12.test;
+
+/**
+ * ClassName: TestInner
+ *
+ * @Author 爱扣钉-陈晨
+ * @Create 2023/11/7 11:21
+ * @Version 1.0
+ */
+public class TestInner {
+    public static void main(String[] args) {
+        Outer.InnerClass innerClass = new Outer().new InnerClass();
+        innerClass.inMethod();
+
+        Outer.InnerClass.inStaticMethod();
+    }
+
+}
+class Outer {
+    private static String a = "外静态a";
+    private  String b = "内非静态b";
+
+    static class InnerStaticClass{
+        private static String a = "内静态a";
+        private  String c = "内非静态c";
+
+        private static void inStaticMethod(){
+            System.out.println("inStaticMethod");
+            System.out.println("Outer.a = " + Outer.a);
+            System.out.println("Inner.a = " + a);
+
+        }
+        private void inMethod(){
+            System.out.println("inMethod");
+            System.out.println("Outer.a = " + Outer.a);
+            //System.out.println("Outer.c = " + Outer.c);//不能访问外部非静态
+            //System.out.println("Outer.c = " + Outer.this.c);//不能访问外部非静态
+            System.out.println("Inner.a = " + a);
+            System.out.println("Inner.a = " + c);
+        }
+
+    }
+
+    class InnerClass{
+        private static String a = "内静态a";
+        private  String c = "内非静态c";
+
+        public static void inStaticMethod(){
+            System.out.println("inStaticMethod");
+            System.out.println("Outer.a = " + Outer.a);
+            System.out.println("Inner.a = " + a);
+        }
+        public void inMethod(){
+            System.out.println("inMethod");
+            System.out.println("Outer.a = " + Outer.a);
+            System.out.println("Outer.c = " + Outer.this.b);
+            System.out.println("Inner.a = " + a);
+            System.out.println("Inner.a = " + c);
+        }
+    }
+
+    abstract class InnerClassAbs{
+
+    }
+
+    final class InnerClassFinal{
+
+    }
+
+    private static void outStaticMethod(){
+        System.out.println("outStaticMethod");
+        System.out.println("InnerStaticClass.a"+InnerStaticClass.a);
+        System.out.println("InnerClass.a"+InnerClass.a);
+    }
+    private void outMethod(){
+        System.out.println("outMethod");
+        System.out.println("InnerStaticClass.a"+InnerStaticClass.a);
+        System.out.println("InnerClass.a"+InnerClass.a);
+    }
+
+    public InnerClass getNoStaticInner(){
+        return new InnerClass();
+    }
+
+}

+ 11 - 0
JavaSe01/day13/day13.iml

@@ -0,0 +1,11 @@
+<?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="jdk" jdkName="17" jdkType="JavaSDK" />
+    <orderEntry type="sourceFolder" forTests="false" />
+  </component>
+</module>

+ 27 - 0
JavaSe01/day13/src/com/lc/day13/exer/Test.java

@@ -0,0 +1,27 @@
+package com.lc.day13.exer;
+
+/**
+ * ClassName: Test
+ *
+ * @Author 爱扣钉-陈晨
+ * @Create 2023/11/8 16:43
+ * @Version 1.0
+ */
+public class Test {
+}
+interface A {
+    int x = 0;
+}
+class B {
+    int x = 1;
+}
+class C extends B implements A {
+    public void pX() {
+        System.out.println(super.x); //指定父类
+        System.out.println(A.x); //指定父类
+    }
+    public static void main(String[] args) {
+        C c = new C();
+        c.pX(); //?
+    }
+}

+ 34 - 0
JavaSe01/day13/src/com/lc/day13/exer/Test01.java

@@ -0,0 +1,34 @@
+package com.lc.day13.exer;
+
+/**
+ * ClassName: Test01
+ *
+ * @Author 爱扣钉-陈晨
+ * @Create 2023/11/8 16:49
+ * @Version 1.0
+ */
+public class Test01 {
+}
+interface Play1Interface {
+    void play();
+}
+interface Play2Interface {
+    void play();
+}
+interface Ball extends Play1Interface, Play2Interface {
+    BasketBall ball = new BasketBall("NBA"); //常量 final
+}
+class BasketBall implements Ball {
+    private String name;
+
+    public String getName() {
+        return name;
+    }
+    public BasketBall(String name) {
+        this.name = name;
+    }
+    public void play() {
+        //ball = new BasketBall("CBA");
+        System.out.println(ball.getName()); // ? 编译
+    }
+}

+ 61 - 0
JavaSe01/day13/src/com/lc/day13/inter01/Test01.java

@@ -0,0 +1,61 @@
+package com.lc.day13.inter01;
+
+/**
+ * ClassName: Test01
+ *
+ * @Author 爱扣钉-陈晨
+ * @Create 2023/11/8 13:58
+ * @Version 1.0
+ */
+public class Test01 {
+
+    public static void main(String[] args) {
+        //多态引用
+        A a = new C();
+        //变量a 输出 A 类型
+        if (a instanceof A){
+            System.out.println("A");
+        }
+
+        //静态成员
+        System.out.println(A.a);
+
+        //调用静态
+        A.m1();
+
+        //调用 默认
+        a.m2();
+
+        //new
+        new A(){
+
+        }; //不是实例化 接口  创建一个子类。
+    }
+}
+interface A {
+    public static final int a = 10;
+
+    //静态
+    static void m1(){
+        System.out.println("m1");
+    }
+    //默认
+    default void m2(){
+        System.out.println("m2");
+    }
+
+}
+interface AA extends A { //接口之间的规则 继承
+
+}
+interface AAA extends A,AA { //多继承
+
+}
+
+class B {
+
+}
+
+class C implements A , AA { //多实现
+
+}

+ 17 - 0
JavaSe01/day13/src/com/lc/day13/inter02/Audi.java

@@ -0,0 +1,17 @@
+package com.lc.day13.inter02;
+
+/**
+ * ClassName: Audi
+ *
+ * @Author 爱扣钉-陈晨
+ * @Create 2023/11/8 15:23
+ * @Version 1.0
+ */
+public class Audi implements CarInterface{
+    @Override
+    public long runCar(double a) {
+        System.out.println("消耗汽油"+a+"ml");
+        return  (long) (Math.random()*System.currentTimeMillis());
+    }
+
+}

+ 33 - 0
JavaSe01/day13/src/com/lc/day13/inter02/CarInterface.java

@@ -0,0 +1,33 @@
+package com.lc.day13.inter02;
+
+/**
+ * ClassName: TestInterface
+ *
+ * @Author 爱扣钉-陈晨
+ * @Create 2023/11/8 15:17
+ * @Version 1.0
+ */
+public interface CarInterface {
+
+    int MAX_SPEED = 220; //常量
+
+    //抽象方法
+    long runCar( double a ); //消耗燃料返回动力 //public abstract 省略
+
+    //静态方法
+    static void m1(){
+        System.out.println("m1");
+    }
+
+    //默认方法
+    default void start(){
+        System.out.println("start");
+    }
+
+    //私有方法
+    private void privateMethod(){
+        System.out.println("私有方法");
+    }
+
+
+}

+ 23 - 0
JavaSe01/day13/src/com/lc/day13/inter02/Test01.java

@@ -0,0 +1,23 @@
+package com.lc.day13.inter02;
+
+/**
+ * ClassName: Test01
+ *
+ * @Author 爱扣钉-陈晨
+ * @Create 2023/11/8 15:22
+ * @Version 1.0
+ */
+public class Test01 {
+    public static void main(String[] args) {
+        //实现接口
+        CarInterface audo = new Audi();
+        long l = audo.runCar(Math.random());
+        System.out.println("动力"+l);
+
+        //默认的
+        audo.start();
+
+        //静态
+        CarInterface.m1();
+    }
+}

+ 54 - 0
JavaSe01/day13/src/com/lc/day13/inter03/Test.java

@@ -0,0 +1,54 @@
+package com.lc.day13.inter03;
+
+/**
+ * ClassName: Test
+ *
+ * @Author 爱扣钉-陈晨
+ * @Create 2023/11/8 16:12
+ * @Version 1.0
+ */
+public class Test {
+    public static void main(String[] args) {
+        C c = new C();
+        c.a(); //B.a  就近选择父类的方法。
+    }
+}
+interface AAA {
+    default void a(){
+        System.out.println("AA.a");
+    }
+}
+interface A extends AAA{
+
+    public static final int AAAA = 10;
+
+    //接口中的重写
+    default void a(){
+        System.out.println("A.a");
+    }
+}
+
+
+abstract class B {
+
+    public static final int AAAA = 20;
+
+    public void a(){
+        System.out.println("B.a");
+    }
+}
+
+class  C extends B implements A , AAA {
+
+    @Override
+    public void a() {
+        //调用接口中方法 手动指定
+        // 接口名.super.方法
+        A.super.a();
+
+        //使用常量
+        System.out.println(B.AAAA); //手动指定 抽象类
+        System.out.println(A.AAAA); //手动指定 接口
+
+    }
+}

BIN
JavaSe01/out/production/day12/com/lc/day12/test/Outer$InnerClass.class


BIN
JavaSe01/out/production/day12/com/lc/day12/test/Outer$InnerClassAbs.class


BIN
JavaSe01/out/production/day12/com/lc/day12/test/Outer$InnerClassFinal.class


BIN
JavaSe01/out/production/day12/com/lc/day12/test/Outer$InnerStaticClass.class


BIN
JavaSe01/out/production/day12/com/lc/day12/test/Outer.class


BIN
JavaSe01/out/production/day12/com/lc/day12/test/Test.class


BIN
JavaSe01/out/production/day12/com/lc/day12/test/TestInner.class


BIN
JavaSe01/out/production/day13/com/lc/day13/exer/A.class


BIN
JavaSe01/out/production/day13/com/lc/day13/exer/B.class


BIN
JavaSe01/out/production/day13/com/lc/day13/exer/Ball.class


BIN
JavaSe01/out/production/day13/com/lc/day13/exer/C.class


BIN
JavaSe01/out/production/day13/com/lc/day13/exer/Play1Interface.class


BIN
JavaSe01/out/production/day13/com/lc/day13/exer/Play2Interface.class


BIN
JavaSe01/out/production/day13/com/lc/day13/exer/Test.class


BIN
JavaSe01/out/production/day13/com/lc/day13/exer/Test01.class


BIN
JavaSe01/out/production/day13/com/lc/day13/inter01/A.class


BIN
JavaSe01/out/production/day13/com/lc/day13/inter01/AA.class


BIN
JavaSe01/out/production/day13/com/lc/day13/inter01/AAA.class


BIN
JavaSe01/out/production/day13/com/lc/day13/inter01/B.class


BIN
JavaSe01/out/production/day13/com/lc/day13/inter01/C.class


BIN
JavaSe01/out/production/day13/com/lc/day13/inter01/Test01$1.class


BIN
JavaSe01/out/production/day13/com/lc/day13/inter01/Test01.class


BIN
JavaSe01/out/production/day13/com/lc/day13/inter02/Audi.class


BIN
JavaSe01/out/production/day13/com/lc/day13/inter02/CarInterface.class


BIN
JavaSe01/out/production/day13/com/lc/day13/inter02/Test01.class


BIN
JavaSe01/out/production/day13/com/lc/day13/inter03/A.class


BIN
JavaSe01/out/production/day13/com/lc/day13/inter03/AAA.class


BIN
JavaSe01/out/production/day13/com/lc/day13/inter03/B.class


BIN
JavaSe01/out/production/day13/com/lc/day13/inter03/C.class


BIN
JavaSe01/out/production/day13/com/lc/day13/inter03/Test.class