[YouTube, JavaBrains] Java 8 Lambda Basics



My SRC



UNIT 01
Using Lambdas - This unit is an introduction to lambdas in Java 8. Learn what lambdas are, the syntax and how to use them. Compare them with anonymous inner classes. Understand functional interfaces and use lambdas to work with legacy interfaces like Runnable.

Introduction
Why Lambdas
Dev setup
Functional vs Object Oriented Programming
Passing Behavior in OOP
Introducing Lambda Expressions
Lambda Expression Examples
Lambda as interface type
Lambdas vs Interface Implementations
Type Inference
Runnable Using Lambdas
Functional Interface
Lambda Exercise
Lambda Exercise Solution



Java 8 Lambda Basics 9 - Lambdas vs Interface Implementations



Greeting.java


1
2
3
4
5
6
7
package org.javalabs;

public interface Greeting {

	public void perform();

}



Greeter.java


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package org.javalabs;

public class Greeter {

	public  void greet(Greeting greeting){
		greeting.perform();
	}

	public static void main(String[] args){

		Greeter greeter = new Greeter();

		Greeting lambdaGreeting = () -> System.out.println("Hello world!");

		Greeting innerClassGreeting  = new Greeting(){
			public void perform(){
				System.out.println("Hello world!");
			}
		};


//		lambdaGreeting.perform();
//		innerClassGreeting.perform();

		greeter.greet(lambdaGreeting);
		greeter.greet(innerClassGreeting);

	}

} // The End of Class