About Java lambda expressions

I tried to write a long article and couldn't write it forever, so I decided to write an article for myself. It may seem like it has already been written, but it is a memo for beginners.

What is a lambda expression?

It's easy to misunderstand that lambda expression = Java (personal prejudice). Let's run the background roughly.

Positioning in Java

It's just a list, so let's actually compare it.

I will write

** Method **

public class ThisIsSample {
	int res;
	private void calculate(int value1, int value2) {
		res = value1 + value2;
	}
}

** Anonymous class **

ThisIsSample printRunOut = new ThisIsSample() {
  public void prt() {
    System.out.println("sample");
  }
};
printRunOut.prt();

** Lambda expression **

ThisIsSample printRunOut = () -> {
  System.out.println("sample");
};
printRunOut.prt();

After all this alone is not clear. I understand that ** type inference ** restores the abbreviation, but I can't say I understand it. It seems that I have to practice it, but I can't compile it now. (?) So, I would like to describe it later.

Reference information

Java functional interface * There is also a summary of lambda expressions. Basics of using Java8 lambda expressions [Java] Super introduction to Java 8 lambda (writing style, functional interface, unique definition, lambda receiving process)

** Addition ** Markdown Notation Cheat Sheet -Qiita List of things I did to write a document in Markdown -Qiita Qiita Markdown Notation List / Cheat Sheet -Qiita

I don't have time, so I'll give it a try ... I will fix it at a later date. (I don't know much about Stream yet)

2019.7.16 postscript Until now, I have nothing to do with the server system, and I have been playing with Excel / Access / VBA in a small office. The reason why Java is now is that by touching RPA composed of Java, I became familiar with the server-side system for the first time other than the Web. ~~ It's a sloppy article ~~, but please take a warm look.

Recommended Posts

About Java lambda expressions
[Introduction to Java] About lambda expressions
Understand Java 8 lambda expressions
Explain Java 8 lambda expressions
[Java] Introduction to lambda expressions
About C # lambda expressions and Linq
Java lambda expressions learned with Comparator
About Lambda, Stream, LocalDate of Java8
Getting started with Java lambda expressions
The origin of Java lambda expressions
How to use Java lambda expressions
About Java interface
[Java] About Java 12 features
[Java] About arrays
Where about java
About Java features
About Java threads
[Java] About interface
About Java class
About Java arrays
Hello Java Lambda
[Java] Lambda expression
About java inheritance
About interface, java interface
Java lambda expression
About List [Java]
About java var
About Java literals
About Java commands
About Java log output
About Java functional interface
Java, about 2D arrays
About class division (Java)
About [Java] [StreamAPI] allMatch ()
About Java StringBuilder class
java neutral lambda expression 1
[Java] About Singleton Class
[Java] Summary of how to abbreviate lambda expressions
About Java method binding
[Java] About anonymous classes
About method splitting (Java)
Java lambda expression variations
[Java Silver] About initialization
About Java Array List
About Java Polymorphism super ()
About inheritance (Java Silver)
Java 8 lambda expression Feature
java lambda expression memo
About Java String class
About Java access modifiers
About Java entry points
About Java 10 Docker support
Personal summary about Java
Java lambda expression [memo]
Studying Java 8 (lambda expression)
[Java] About enum type
[For beginners] About lambda expressions and Stream API
Review java8 ~ Lambda expression ~
All about Java programming
Java lambda expression again
About java abstract class