Topics

Leave a Reply

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

Notify of
avatar

Imran Butt
Guest
Imran Butt
7 days 14 hours 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
1 month 24 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
6 months 14 days ago

Thank you very much.

Baba Gilo
Guest
Baba Gilo
8 months 2 days ago

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

Rookie Cookie
Guest
Rookie Cookie
8 months 2 days ago

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

wpDiscuz