package com.sf._06_内部类._03_匿名内部类;

import com.sf._03_接口入门案例.ISwim;

public class Test {
    public static void main(String[] args) {
//        ISwim swim = new Student();
//        swim.swimming();

        /**
         * 前提：
         * 继承/实现关系当中
         *
         * new  接口（）{
         *     重写方法swimming(){
         *
         *     }
         * }
         */

//        // 就相当于你创建了一个Dog 类实现了ISwim 接口
//        ISwimable iable = new ISwimable() {
//            @Override
//            public void swimming() {
//                System.out.println("鱼游泳");
//            }
//        };
//        iable.swimming();
//
//        // 就相当于你创建了一个Dog 类实现了ISwim 接口
//        new ISwimable() {
//            @Override
//            public void swimming() {
//                System.out.println("狗游泳");
//            }
//        }.swimming();
        ISwim swim = new Student();
        swim(swim);

        swim(new Dog());

        swim(new ISwim() {
            @Override
            public void swimming() {
                System.out.println("鱼游泳");
            }
        });
    }


    public static void swim(ISwim swim){
        swim.swimming();
    }
}
