How to understand the Java Lambda expression demo
This article shows you how to understand Java Lambda expression demo, the content is concise and easy to understand, absolutely can make your eyes shine, through the detailed introduction of this article I hope you can gain something.
public class Solution { public static void process(Runnable r){ r.run(); } public static void main(String[] args) { //Use lambda expressions Runnable r1 = () -> System.out.println("Hello World 1"); //Use anonymous classes Runnable r2 = new Runnable(){ public void run(){ System.out.println("Hello World 2"); } }; process(r1); process(r2); //Lambda is passed directly as input parameter process(() -> System.out.println("Hello World 3")); }} That's how to understand Java Lambda expression demo, have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserves, please pay attention to the industry information channel.