New features of Java8 - Lambda functional programming

foreword

   Java has always been an object-oriented language, everything is an object, if you want to call a function, the function must belong to a class or object, and then use the class or object to call.
In Java, "." means calling a method of an object

   //例如调用object的hashCode方法
  Object o=new Object();
     o.hashCode();

    Everything is an object. From an understanding point of view, there is nothing wrong with object-oriented programming, but from a development point of view, object-oriented programming may beWrite a lot of meaningless code.
For example using Runnable anonymous class

Runnable runnable = new Runnable() {
    
    
    @Override
    public void run() {
    
    
        System.out.println("runnable task...");
    }
};

   The above code really only uses the output statement in the run method , and the other parts are the basic components of the object, which have no practical effect, but must be written. In order to facilitate more efficient CRUD for programmers, Java 8 has introduced functional programming interfaces and Lambda expressions to help us write less and more elegant code:

  //一行搞定
Runnable runnable = () -> System.out.println("runnable task...");

Lambda expressions can be understood as a piece of code that can be passed. Passing the code like data can make the code more concise and flexible, and help us write less and more elegant code

Lambda coding is cool for a while, debugging the crematorium, so, do you have any good solutions for debugging?

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324145073&siteId=291194637