lambda expression in Java

Table of Contents 1. Background 2. Basic use of lambda expressions 3. Variable capture 4. Use of lambda in collections (map and set) 5. Advantages and Disadvantages 1. Background (1). Definition of lambda expression: (2) Syntax of lambda expression: (3) Functional interface 2. Basic use of lambda expressions (1) Without using lambda expression, simply call […]

NReco.LambdaParser use case

Use case collection: private async void RuleEngine_Click(object sender, EventArgs e) { #region Get variables string expression = this.Rule.Text.Trim(); string pattern = @”\$(.*?)\$”; MatchCollection matches = Regex.Matches(expression, pattern); foreach (Match match in matches) { string variableName = match.Groups[1].Value; } #endregion #region executor initialization var lambdaParser = new LambdaParser(); lambdaParser.AllowVars = true; #endregion #region variable initialization var […]

lambda expression advanced

1. Functional interface An interface with only one abstract method is called a functional interface. JDK’s functional interfaces are marked with the @FunctionalInterface annotation. But regardless of whether the annotation is added or not, as long as there is only one abstract method in the interface, it is a functional interface. 2. Method reference When […]

java8 Lambda expression and Stream stream

Lambda expression Lambda expression rules A lambda expression can be thought of as a piece of code that can be passed around. Lambda expressions can only be used for functional interfaces, and functional interfaces have only one abstract method, so the method name, parameter type, etc. can be omitted Lambda format: (formal parameter list) -> […]

Learn how to use lambda expressions

1. Overview Lambda is a syntax sugar in JDK8. He can simplify the writing of some anonymous inner classes. It is an important embodiment of functional programming thinking. Let us not focus on what the object is. Instead, we focus more on what we do with the data. 2. Basic format of lambda expression (parameter […]

A preliminary study on Java anonymous inner classes and lambda expressions

Article directory Preface 1. Anonymous inner classes 1.Features 2. Grammar (examples) 2. Lambda expression 1.Features 2. Grammar (examples) 3. Java event processing mode 1.Writing 1 2.Writing 2 3.Writing 3 4.Writing 4 Foreword When writing Java event processing recently, I basically used the traditional Java event processing mechanism at the beginning, new the implemented interface object, […]

# Development Trend Java Lambda Expression Part 3

Development Trend Java Lambda Expression Part 3 1. Lambda integration collection + common operations List Java Lambda expressions can be integrated with List collections and regular operations to provide a cleaner and more readable way to write code. Here are a few examples: Collection traversal operation: List<String> names = Arrays.asList(“John”, “Mary”, “Alice”); // Use foreach […]

C++11 – lambda expressions

Article directory 1. C++98 sorting of custom types 2. lambda expression syntax 2.1 Capture list 3. The underlying principle of lambda 1. C++98 sorting of custom types In C++98, if we want to sort custom types, we have to write our own functor to indicate which item we are sorting relative to struct Student {<!– […]

Kotlin lambda-Capturing vs Non-Capturing Lambdas

Overview I believe that many people are confused when they see Capturing/non-capturing lambdas. What is this? It seems that they have not seen this in actual use. In fact, we encounter this thing every day in actual development, but we are not very familiar with this concept. Today I will talk about this thing. After […]

String constant pool, reflection, enumeration, Lambda

Table of Contents 1. String constant pool 1. Concept 2.Examples 3.intern method 2. Reflection 1. Concept 2. Reflection related classes 3.Related methods in the Class class 4.Reflection example 3. Enumeration 1. Define an enumeration type 2. Common methods of enumeration types 3. Enumeration methods come from inheritance 4.Construction method of enumeration 5. Reflection enumeration type […]