Skip to main content

All Questions

Tagged with
8 votes
0 answers
822 views

What lambda function optimizations, if any, are planned for Java 9 and beyond? [closed]

I'm working on a high-performance project where Java 8's lambda functions are enormously useful. I've found, however, that they're memory inefficient when used en masse. For example, suppose I need to ...
Dylan Knowles's user avatar
0 votes
1 answer
85 views

How confusing is `new SomeCollection(values...)::contains` as a Predicate? [closed]

Traditionally, a function that want to skip certain items during processing will accept a Collection or var-args argument, but in the Java 8 world I think I should switch to Predicates. Now, since ...
billc.cn's user avatar
  • 630
50 votes
4 answers
22k views

Why should I use "functional operations" instead of a for loop?

for (Canvas canvas : list) { } NetBeans suggests me to use "functional operations": list.stream().forEach((canvas) -> { }); But why is this preferred? If anything, it is harder to read and ...
Saturn's user avatar
  • 3,937
71 votes
3 answers
34k views

Is there a performance benefit to using the method reference syntax instead of lambda syntax in Java 8?

Do method references skip the overhead of the lambda wrapper? Might they in the future? According to the Java Tutorial on Method References: Sometimes... a lambda expression does nothing but call an ...
GlenPeterson's user avatar
  • 14.9k
5 votes
3 answers
543 views

Does it make sense to split up an existing multi-method interface into several single method interfaces just to take advantage of lambdas?

Say I have an existing callback interface that has multiple methods. To illustrate my point I use a callback the likes that you would see in code that performs some HTTP client operations: public ...
curioustechizen's user avatar
2 votes
2 answers
6k views

How the Stream.filter() method works?

I know how the lambda expresion works and I know it is an argument for .filter() that establish the criteria to filter with. But I don't get how .filter() uses the argument, in this case a lambda ...
user3727894's user avatar
31 votes
1 answer
17k views

Type inference in Java 8

Is the introduction of the new lambda notation (see e.g. this article) in Java 8 going to require some kind of type inference? If so, how will the new type system impact the Java language as a whole?
Giorgio's user avatar
  • 19.8k