Java教程

Lambda

本文主要是介绍Lambda,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
package com.student_thread.lambda;
public class Lambda {
        //3.静态内部类
        static class Like2 implements ILike{
            @Override
            public void Lambda() {
                System.out.println("I STUDENT LAMBDA PART TWO");
            }
        }


        public static void main(String[] args) {

            ILike like=new Like();
            like.Lambda();

            like = new Like2();
            like.Lambda();

            //4.局部内部类
            class Like3 implements ILike{
                @Override
                public void Lambda() {
                    System.out.println("I STUDENT LAMBDA PART THREE");
                }
            }
            like = new Like3();
            like.Lambda();

            //5.匿名内部类
            like =new ILike(){
                @Override
                public void Lambda() {
                    System.out.println("I STUDENT LAMBDA PART FOUR");
                }
            };
            like.Lambda();

            //6.用lambda简化测试
            like=()->{
                System.out.println("I STUDENT LAMBDA PART FIVE");
            };
            like.Lambda();



        }


    static class Like implements ILike{
        @Override
        public void Lambda(){
            System.out.println("LAMBDA PART ONE");
        }
    }

    interface ILike{
        void Lambda();
    }

}

 

这篇关于Lambda的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!