Timeline for Is there a performance benefit to using the method reference syntax instead of lambda syntax in Java 8?
Current License: CC BY-SA 3.0
5 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Oct 22, 2019 at 7:34 | comment | added | Roland Tepp | Thank you @StefanReich, That was very helpful! | |
Oct 14, 2019 at 11:39 | comment | added | Stefan Reich | That answer is simply wrong | |
Feb 24, 2017 at 23:50 | comment | added | squid314 |
Java lambdas are not strictly closures. Nor are they anonymous inner classes. They do NOT carry a reference to all variables in scope where they are declared. They ONLY carry a reference to the variables they actually reference. This also applies to the this object which could be referenced. A lambda, therefore, does not leak resources simply by having scope for them; it only holds on to the objects it needs. On the other hand, an anonymous inner class can leak resources, but does not always do so. See this code for an example: a.blmq.us/2mmrL6v
|
|
Jul 21, 2016 at 11:21 | comment | added | Ajax | Same goes for non-static method references. | |
Nov 12, 2015 at 21:55 | history | answered | Roland Tepp | CC BY-SA 3.0 |