-
Notifications
You must be signed in to change notification settings - Fork 123
Expand file tree
/
Copy pathThisDemo.java
More file actions
28 lines (23 loc) · 822 Bytes
/
ThisDemo.java
File metadata and controls
28 lines (23 loc) · 822 Bytes
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
package com.eazybytes.lambda;
public class ThisDemo {
public static void main(String[] args) {
ThisDemo thisDemo = new ThisDemo();
Printer lambdaPrinter = thisDemo.getLambdaPrinter();
lambdaPrinter.print("Lambda Expression");
Printer anonymousPrinter = thisDemo.getAnonymousPrinter();
anonymousPrinter.print("Anonymous Inner Class");
}
public Printer getLambdaPrinter() {
Printer printer = msg -> System.out.println(msg + " : " + this.getClass());
return printer;
}
public Printer getAnonymousPrinter() {
Printer printer = new Printer() {
@Override
public void print(String input) {
System.out.println(input + " : " + this.getClass());
}
};
return printer;
}
}