Topics

Leave a Reply

6 Comments on "Java 8 Lambda Basics 19 – Closures in Lambda Expressions"

Notify of
avatar

Rajat Mishra
Guest
Rajat Mishra
3 months 23 days ago

Where do you read about all these interesting things? Do you follow a book? Please recommend.

Imran Butt
Guest
Imran Butt
3 months 30 days ago

All tutorials are awesome !!!Step by Step and first elaborating what we were doing right now and what particular change we should do, elaborates every detail.Hats Off 🙂

Jarl Øystein Samseth
Guest
Jarl Øystein Samseth
5 months 17 days ago
You're tutorials are superb. However, I just wanted to note that you can change the value of variable b, inside the lambda expression. I may have misunderstood you, but I wouldn't call it final if I change the b-value in the lambda expression. Then again, I haven't fully grasped the "effectively final" expression.I tested it by the following code:public class Main { static int b=2; void a(Runnable r){r.run();} public static void main(String[] args) { Main m = new Main(); m.a(()-> System.out.println(b)); m.a(()-> {b++; System.out.println(b);}); System.out.println(b); Runnable x = () -> {b++; System.out.println(b);}; m.a(x); m.a(x); m.a(x); }}This gave the output:233456Hence b… Read more »
Guram Kankava
Guest
Guram Kankava
10 months 6 days ago

Thank you very much.

Baba Gilo
Guest
Baba Gilo
11 months 25 days ago

What do you think if we always use $ as the method name in functional interface?

Rookie Cookie
Guest
Rookie Cookie
11 months 25 days ago

I remember closures in JavaScript course. Just interesting to compare.

wpDiscuz