Notes
lambda Expression
Content of the notes (7)
Page 1
What is lambda expression for?
Example:
only one method in this interface
public interface FileFilter(){
pblic boolean filter(File file);
}
Ways to use this interface:
By implementing this interface
public class File implements FileFilter{
@override
public void boolean filter(){
return true;
}
}
File f=new File();
f.filter(f);
2. By making anonymous class
public class File{
FileFilter f=new FileFilter(){
@override
public boolean filter(){
return true;
}
}
}
Page 2
To make instance of anonymous inner class easier to write and read.
Another way to write instances for anonymous java inner class.
FileFilter f=(File file) -> true;
Page 3
Practical Example for Lambda implementation
l
Page 4
Example with Runnable interface.
Page 5
Lambda with Comparators:
Page 6
More on Functional interface:
Page 7
Information
- Description
- Coding (Java 8) Note on lambda Expression, created by Naveen G on 20/11/2017.
- Created by
- Naveen G
- Views
- 0
- Rating