public class ATeacher extends Teacher{
    	@Override
    	public void work() {

    	}
		}
		
        
            
		public abstract class Person {

		private String name;
		private int age;

		//作用:当创建子类对象的时,给属性进行赋值的。
		public Person() {
		}

		public Person(String name, int age) {
			this.name = name;
			this.age = age;
		}

		public String getName() {
			return name;
		}

		public void setName(String name) {
			this.name = name;
		}

		public int getAge() {
			return age;
		}

		public void setAge(int age) {
			this.age = age;
		}

		public abstract void work();

		public void sleep(){
			System.out.println("睡觉");
		}
		}
		
        
            
		public class Student extends Person{


		public Student() {
		}

		public Student(String name, int age) {
			super(name, age);
		}

		@Override
		public void work() {
			System.out.println("学生的工作是学习");
		}
		}
		
        
            
		public abstract class Teacher extends Person{
		}
		
        
            
		public class Test {
    	public static void main(String[] args) {
        //创建对象
        //Person p = new Person();


        Student s = new Student("zhangsan",23);

        System.out.println(s.getName() + ", " + s.getAge());
    	}
		}
		
        
            
		public abstract class Animal {
		private String name;
		private int age;

		public Animal() {
		}

		public Animal(String name, int age) {
			this.name = name;
			this.age = age;
		}


		public String getName() {
			return name;
		}

		public void setName(String name) {
			this.name = name;
		}

		public int getAge() {
			return age;
		}

		public void setAge(int age) {
			this.age = age;
		}

		public void drink(){
			System.out.println("动物在喝水");
		}

		public abstract void eat();
		}
		
        
            
		
		
        
            
		public class Dog extends Animal{


		public Dog() {
		}

		public Dog(String name, int age) {
			super(name, age);
		}

		@Override
		public void eat() {
			System.out.println("狗吃骨头");
		}
		}
		
        
            
		public class Frog extends Animal{

		public Frog() {
		}

		public Frog(String name, int age) {
			super(name, age);
		}

		@Override
		public void eat() {
			System.out.println("青蛙在吃虫子");
		}
		}
		
        
            
		public class Sheep extends Animal{

		public Sheep() {
		}

		public Sheep(String name, int age) {
			super(name, age);
		}

		@Override
		public void eat() {
			System.out.println("山羊在吃草");
		}
		}
		
        
            
		public class Test {
    	public static void main(String[] args) {
        //创建对象



        Frog f = new Frog("小绿",1);
        System.out.println(f.getName() + ", " + f.getAge());
        f.drink();
        f.eat();
    	}
  		}
		
        
            
		public class Car {
		String carName;
		int carAge;
		String carColor;


		public void show(Car this){
			//是打印调用者车的名字:宾利
			System.out.println(this.carName);
			Engine e = new Engine();
			System.out.println(e.engineName);
		}


		class Engine{
			String engineName;
			int engineAge;

			public void show(){
				System.out.println(engineName);
				System.out.println(carName);
			}
		}
		}
		
        
            
		public class Test {
    	public static void main(String[] args) {
        /*
            需求:写一个Javabean类描述汽车。
            属性:汽车的品牌,车龄,颜色,发动机的品牌,使用年限。

            内部类的访问特点:
                内部类可以直接访问外部类的成员,包括私有
                外部类要访问内部类的成员,必须创建对象

        */

        Car c = new Car();
        c.carName = "宾利";
        c.carAge = 1;
        c.carColor = "粉色";

        c.show();
    	}
		}
		
        
            
		public class Outer {
		String name;

		private class Inner{
			static int a = 10;
		}


		public Inner getInstance(){
			return new Inner();
		}


		}
			
        
            
		public class Test {
    	public static void main(String[] args) {
       /*
        编写成员内部类的注意点:
            1.成员内部类可以被一些修饰符所修饰,比如: private,默认,protected,public,static等
            2.在成员内部类里面,JDK16之前不能定义静态变量,JDK16开始才可以定义静态变量。

        获取成员内部类对象的两种方式:
            方式一:外部类编写方法,对外提供内部类对象(private)

            方式二:直接创建
            格式:外部类名.内部类名 对象名 = 外部类对象.内部类对象;
            范例:Outer.Inner oi = new Outer().new Inner();
        */


        //创建对象的方式:
        //类名 对象名 = new 类名();
        //Student s = new Student();

        //我要创建的是谁的对象?
        //内部类的对象

       // Outer.Inner oi = new Outer().new Inner();

        Outer o = new Outer();
        System.out.println(o.getInstance());


    	}
		}
		
        
            
		public class Outer {
    	private int a = 10;

    	class Inner {
        private int a = 20;

        public void show() {
            int a = 30;
            //Outer.this 获取了外部类对象的地址值
            System.out.println(Outer.this.a);//10
            System.out.println(this.a); //20
            System.out.println(a); //30
        }
    	}
		}
		
        
            
		import java.util.Scanner;

		public class Test {
    	public static void main(String[] args) {
        //创建内部类的对象,并调用show方法
        Outer.Inner oi = new Outer().new Inner();

        oi.show();


        Scanner sc = new Scanner(System.in);
        sc.next();
    	}
		}
		
        
            
		public class Outer {

		//int a = 10;
		//static int b = 20;

		//静态内部类
		static class Inner {
			public void show1(){
				System.out.println("非静态的方法被调用了");
			}

			public static void show2(){
				System.out.println("静态的方法被调用了");
			}
		}
		}
		
        
            
		public class Test {
    	public static void main(String[] args) {
        //注意事项:
        //1.静态内部类也是成员内部类中的一种
        //2.静态内部类只能访问外部类中的静态变量和静态方法,
        //  如果想要访问非静态的需要创建外部类的对象。

        //创建静态内部类对象的格式:
        //      外部类名.内部类名 对象名 = new 外部类名.内部类名();
        //调用静态方法的格式:
        //      外部类名.内部类名.方法名();


        //创建静态内部类的对象
        //只要是静态的东西,都可以用类名点直接获取
        Outer.Inner oi = new Outer.Inner();
        oi.show1();

        //静态方法
        Outer.Inner.show2();

    	}
		}
		
        
            
		public class Outer {

    	int b = 20;

    	public void show(){
        int a = 10;

        //局部内部类
        class Inner{
            String name;
            int age;

            public void method1(){
                System.out.println(a);
                System.out.println(b);
                System.out.println("局部内部类中的method1方法");
            }

            public static void method2(){
                System.out.println("局部内部类中的method2静态方法");
            }
        }

        //创建局部内部类的对象
        Inner i = new Inner();
        System.out.println(i.name);
        System.out.println(i.age);
        i.method1();
        Inner.method2();
    	}
		}
		
        
            
		public class Test {
    	public static void main(String[] args) {
        /*
        局部内部类
        1.将内部类定义在方法里面就叫做局部内部类,类似于方法里面的局部变量。
        2.外界是无法直接使用局部内部类,需要在方法内部创建对象并使用。
        3.该类可以直接访问外部类的成员,也可以访问方法内的局部变量。*/


        //调用show方法,让代码执行
        Outer o = new Outer();
        o.show();

    	}
		}
		
        
            
		public abstract class Animal {
    	public abstract void eat();
		}
		
        
            
		public class Dog extends Animal{
    	@Override
    	public void eat() {
        System.out.println("狗吃骨头");
    	}
		}
		
        
            
		public interface Swim {
    	public abstract void swim();
		}
		
        
            
		public class Test {

    	public static void main(String[] args) {
       /*
            需要大家理解匿名内部类的格式,而不是硬记:
                new 类名或者接口名() {
                 重写方法;
                };
        */

        //编写匿名内部类的代码
        new Swim(){
            @Override
            public void swim() {
                System.out.println("重写了游泳的方法");
            }
        };


        new Animal(){
            @Override
            public void eat() {
                System.out.println("重写了eat方法");
            }
        };

        //在测试类中调用下面的method方法?
        //以前的方式如何调用?
        //要自己写一个子类继承Animal类
        //再创建子类的对象,传递给method方法
       /* Dog d = new Dog();
        method(d);*/
        //如果Dog类我只要用一次,那么还需要单独定义一个类太麻烦了。

        method(

                new Animal() {
                    @Override
                    public void eat() {
                        System.out.println("狗吃骨头");
                    }
                }

        );
    	}
		public static void method(Animal a){//Animal a = 子类对象 多态
			a.eat();//编译看左边,运行看右边
		}
		}
		
        
            
		public class Test2 {

    	//是一个没有名字的成员内部类
    	Swim s = new Swim(){

        @Override
        public void swim() {
            System.out.println("重写之后游泳方法");
        }
		};



		public static void main(String[] args) {
			//回顾一下匿名内部类的格式
			/*
			*
			*           new 类/接口(){
			*               重写的方法;
			*           }
			*
			*
			* */

			//整体我们可以理解为Swim接口的实现类对象
			//接口多态
			Swim s = new Swim(){

				@Override
				public void swim() {
					System.out.println("重写之后游泳方法");
				}
			};

			//编译看左边,运行看右边的原则
			s.swim();

			new Swim(){

				@Override
				public void swim() {
					System.out.println("重写之后游泳方法");
				}
			}.swim();

		}
		}
		
        
            
		public abstract class Animal {
		private String name;
		private int age;


		public Animal() {
		}

		public Animal(String name, int age) {
			this.name = name;
			this.age = age;
		}

		public String getName() {
			return name;
		}

		public void setName(String name) {
			this.name = name;
		}

		public int getAge() {
			return age;
		}

		public void setAge(int age) {
			this.age = age;
		}


		public abstract void eat();

		}
		
        
            
		public class Dog extends Animal implements Swim{

		public Dog() {
		}

		public Dog(String name, int age) {
			super(name, age);
		}

		@Override
		public void eat() {
			System.out.println("狗吃骨头");
		}

		@Override
		public void swim() {
			System.out.println("狗刨");
		}
		}
		
        
            
		public class Frog extends Animal implements Swim{

		public Frog() {
		}

		public Frog(String name, int age) {
			super(name, age);
		}

		@Override
		public void eat() {
			System.out.println("青蛙在吃虫子");
		}

		@Override
		public void swim() {
			System.out.println("青蛙在蛙泳");
		}
		}
		
        
            
		public class Rabbit extends Animal{


		public Rabbit() {
		}

		public Rabbit(String name, int age) {
			super(name, age);
		}

		@Override
		public void eat() {
			System.out.println("兔子在吃胡萝卜");
		}
		}
		
        
            
		public interface Swim {

    	public abstract void swim();

		}
		
        
            
		public class Test {

    	public static void main(String[] args) {
       //创建青蛙的对象
       Frog f = new Frog("小青",1);
        System.out.println(f.getName() + ", " + f.getAge());

        f.eat();
        f.swim();

        //创建兔子的对象
        Rabbit r = new Rabbit("小白",2);
        System.out.println(r.getName() + ", " + r.getAge());
        r.eat();
    	}
		}
		
        
            
		public interface Inter {
		//public static final
		int a = 10;

		//public abstract
		void method();
		}
		
        
            
		public class InterImpl implements Inter{
		@Override
		public void method() {
			System.out.println("method");
		}
		}
		
        
            
		import java.util.Scanner;

		/*
			成员变量
				只能是常量,默认修饰符:public static final
			构造方法
				没有
			成员方法
				只能是抽象方法,默认修饰符:public abstract
		*/
		public class Test {
			public static void main(String[] args) {

        //创建实现类对象并调用方法
        InterImpl ii = new InterImpl();
        ii.method();


        Scanner sc = new Scanner(System.in);
        sc.next();

    	}
		}
		
        
            
		public interface Inter1 {
		public abstract void method1();
		public abstract void method2();
		public abstract void method3();
		}
		
        
            
		public interface Inter2 {
		public abstract void method1();
		public abstract void method2();
		public abstract void method3();
		public abstract void method4();
		}	
		
        
            
		public class InterImpl implements Inter1,Inter2{

		@Override
		public void method1() {
			System.out.println("method1");
		}

		@Override
		public void method2() {
			System.out.println("method2");
		}

		@Override
		public void method3() {
			System.out.println("method3");
		}

		@Override
		public void method4() {
			System.out.println("method4");
		}
		}
		
        
            
		public class Test {
		public static void main(String[] args) {
		// 类和接口之间的关系:
		//      实现关系,可以单实现,也可以多实现,还可以在继承一个类的同时实现多个接口
    	}
		}
		
        
            
		public interface Inter1 {
    	public abstract void method1();
		}
		
        
            
		public interface Inter2 {
    	public abstract void method2();
		}
		
        
            
		public interface Inter3 extends Inter1,Inter2{
    	public abstract void method3();
		}
		
        
            
		public class InterImpl implements Inter3{
		@Override
		public void method1() {

		}

		@Override
		public void method2() {

		}

		@Override
		public void method3() {

		}
		}
			
        
            
		public class Test {
    	public static void main(String[] args) {
        //接口和接口之间是继承关系,可以单继承,也可以多继承
        //细节:如果实现类实现了最下面的子接口,那么就需要重写所有的抽象方法
   		 }
		}
		
        
            
		public class BasketballCoach extends Coach{

		public BasketballCoach() {
		}

		public BasketballCoach(String name, int age) {
			super(name, age);
		}

		@Override
		public void teach() {
			System.out.println("篮球教练正在教如何打篮球");
		}
		}
		
        
            
		public class BasketballSporter extends Sporter{

		public BasketballSporter() {
		}

		public BasketballSporter(String name, int age) {
			super(name, age);
		}

		@Override
		public void study() {
			System.out.println("篮球运动员在学习如何打篮球");
		}
		}
		
        
            
		public abstract class Coach extends Person{

		public Coach() {
		}

		public Coach(String name, int age) {
			super(name, age);
		}

		public abstract void teach();
		}
		
        
            
		public interface English {
    	public abstract void speakEnglish();
		}
		
        
            
		//因为现在我不想让外界去直接创建人的对象
		//因为直接创建顶层父类人的对象此时是没有意义的
		//所以我就把他写为抽象的。
		public abstract class Person {
		private String name;
		private int age;

		public Person() {
		}

		public Person(String name, int age) {
			this.name = name;
			this.age = age;
		}

		public String getName() {
			return name;
		}

		public void setName(String name) {
			this.name = name;
		}

		public int getAge() {
			return age;
		}

		public void setAge(int age) {
			this.age = age;
		}
		}
		
        
            
		public class PingPangCoach extends Coach implements English{

		public PingPangCoach() {
		}

		public PingPangCoach(String name, int age) {
			super(name, age);
		}

		@Override
		public void teach() {
			System.out.println("乒乓球教练正在教如何打乒乓球");
		}

		@Override
		public void speakEnglish() {
			System.out.println("乒乓球教练在学习说英语");
		}
		}
		
        
            
		public class PingPangSporter extends Sporter implements English{

		public PingPangSporter() {
		}

		public PingPangSporter(String name, int age) {
			super(name, age);
		}

		@Override
		public void speakEnglish() {
			System.out.println("乒乓球运动员在说英语");
		}

		@Override
		public void study() {
			System.out.println("乒乓球运动员在学习如何打乒乓球");
		}
		}
		
        
            
		public abstract class Sporter extends Person{

		public Sporter() {
		}

		public Sporter(String name, int age) {
			super(name, age);
		}

		public abstract void study();
		}
		
        
            
		public class Test {
    	public static void main(String[] args) {
        //创建运动员或教练的对象

        PingPangSporter pps = new PingPangSporter("刘诗雯",23);
        System.out.println(pps.getName() + ", " + pps.getAge());
        pps.study();
        pps.speakEnglish();

    	}
		}
		
        
            
		public interface InterA {
     		/*接口中默认方法的定义格式:
            格式:public default 返回值类型 方法名(参数列表) {   }

        接口中默认方法的注意事项:
            1.默认方法不是抽象方法,所以不强制被重写。但是如果被重写,重写的时候去掉default关键字
            2.public可以省略,default不能省略
            3.如果实现了多个接口,多个接口中存在相同名字的默认方法,子类就必须对该方法进行重写*/


		public abstract void method();

		public default void show(){
			System.out.println("InterA接口中的默认方法 ---- show");
		}
		}
		
        
            
		public interface InterB {
		public default void show(){
			System.out.println("InterB接口中的默认方法 ---- show");
		}
		}

		
        
            
		public class InterImpl implements InterA,InterB{
		@Override
		public void method() {
			System.out.println("实现类重写的抽象方法");
		}

		@Override
		public void show() {
			System.out.println("重写接口中的默认方法");
		}
		}
		
        
            
		public class Test {
    	public static void main(String[] args) {
        /*接口中默认方法的定义格式:
            格式:public default 返回值类型 方法名(参数列表) {   }

        接口中默认方法的注意事项:
            1.默认方法不是抽象方法,所以不强制被重写。但是如果被重写,重写的时候去掉default关键字
            2.public可以省略,default不能省略
            3.如果实现了多个接口,多个接口中存在相同名字的默认方法,子类就必须对该方法进行重写





            */


        //创建实现类的对象
        //InterImpl ii = new InterImpl();
        //ii.show();
    	}
		}
		
        
            
		public interface Inter {

		public abstract void method();

		public static void show(){
			System.out.println("Inter接口中的静态方法");
		}
		}
		
        
            
		public class InterImpl implements Inter{
		@Override
		public void method() {
			System.out.println("InterImpl重写的抽象方法");
		}

		//不叫重写
		public static void show() {
			System.out.println("InterImpl重写的抽象方法");
		}

		}
		
        
            
		public class Test {
    	public static void main(String[] args) {
        /*
            接口中静态方法的定义格式:
                格式:public static 返回值类型 方法名(参数列表) {   }
                范例:public static void show() {   }

               接口中静态方法的注意事项:
                    静态方法只能通过接口名调用,不能通过实现类名或者对象名调用
                    public可以省略,static不能省略
        */


        //调用接口中的静态方法
        Inter.show();

        //调用实现类中的静态方法
        InterImpl.show();

        //子类把从父类继承下来的虚方法表里面的方法进行覆盖了,这才叫重写。

    	}
		}	
		
        
            
		public interface InterA {

		public static void show1(){
			System.out.println("show1方法开始执行了");
			show4();
		}


		public static void show2(){
			System.out.println("show2方法开始执行了");
			show4();
		}


	   //普通的私有方法,给默认方法服务的
		private void show3(){
			System.out.println("记录程序在运行过程中的各种细节,这里有100行代码");
		}


		//静态的私有方法,给静态方法服务的
		private static void show4(){
			System.out.println("记录程序在运行过程中的各种细节,这里有100行代码");
		}
		}
			
        
            
		public class Test {
    	public static void main(String[] args) {
      /*  接口中私有方法的定义格式:

        格式1:private 返回值类型 方法名(参数列表) {   }
        范例1:private void show() {   }

        格式2:private static 返回值类型 方法名(参数列表) {   }
        范例2:private static void method() {   }
		*/
    	}
		}
		
        
            
		public interface Inter {
		public abstract void method1();
		public abstract void method2();
		public abstract void method3();
		public abstract void method4();
		public abstract void method5();
		public abstract void method6();
		public abstract void method7();
		public abstract void method8();
		public abstract void method9();
		public abstract void method10();
		}
		
        
            
		public abstract class InterAdapter implements Inter{

		@Override
		public void method1() {

		}

		@Override
		public void method2() {

		}

		@Override
		public void method3() {

		}

		@Override
		public void method4() {

		}

		@Override
		public void method5() {

		}

		@Override
		public void method6() {

		}

		@Override
		public void method7() {

		}

		@Override
		public void method8() {

		}

		@Override
		public void method9() {

		}

		@Override
		public void method10() {

		}
		}
		
        
            
		public class InterImpl extends InterAdapter{
	  	//我需要用到那个方法,就重写哪个方法就可以了

		@Override
		public void method5() {
			System.out.println("只要用第五个方法");
		}
		}
		
        
单词