Java 8 refers to the newest version of the Java platform.

learn more… | top users | synonyms

1
vote
1answer
222 views

What is the “->” symbol called?

I have seen the -> operator/symbol in Java 8 predicates recently and wondered what its name is. I know that it is used in lambda expressions, but I know that the symbol for lambda is λ, so that's ...
0
votes
0answers
33 views

Can't figure out how to parallelize the calculation of the amount of offspring expected for species in genetic algorithm

I developed a genetic algorithm in java 8 taking advantage of its reasonably free parallelism opportunities with Streams. As you are likely aware, running the epochs takes its time for even a test ...
13
votes
1answer
322 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 ...
1
vote
2answers
69 views

Is it a good idea to contextually name predefined functional interfaces?

I am currently working with Java 8 and using functional interfaces a lot. I often find myself writing code like this: public interface MessageHandler extends Consumer<String> { } Is this a ...
11
votes
3answers
3k views

What is the name of a function that takes no argument and returns nothing? [closed]

In Java 8's java.util.function package, we have: Function: Takes one argument, produces one result. Consumer: Takes one argument, produces nothing. Supplier: Takes no argument, produces one result. ...
12
votes
3answers
447 views

Is it a sane thing to return Streams wherever we would normally return Collections?

While developing my API that is not tied to any legacy code, I often find myself writing methods that are purely Streams pipeline terminated by collecting the results. Like this one: ...
0
votes
2answers
110 views

Java Streams API Documentation

Currently learning Java so this may be a question resulting from lack of understanding of Java (while also learning Streams API) In the declarations of function I often see two templated types for ...
5
votes
3answers
246 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 ...
1
vote
2answers
122 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 ...
2
votes
2answers
444 views

Is there any reason not to use Optional as a method argument in the case where you know the argument is something that may or may not be needed?

With Java 8, I've seen more and more articles about the use of Option/Optional. I understand what they trying to represent, and I see many examples of them being used as returns. However what I don't ...
18
votes
4answers
12k views

Why were default and static methods added to interfaces in Java 8 when we already had abstract classes?

In Java 8, interfaces can contain implemented methods, static methods, and the so-called "default" methods (which the implementing classes do not need to override). In my (probably naive) view, there ...
8
votes
1answer
668 views

Passing a Scala function to a Java 8 method

The following Scala code works and can be passed to a Java method expecting a function. Is there a cleaner way to do this? Here's my first pass: val plusOne = new ...
24
votes
4answers
4k views

Workaround for Java checked exceptions

I appreciate a lot the new Java 8 features about lambdas and default methods interfaces. Yet, I still get bored with checked exceptions. For instance, if I just want to list all the visible fields of ...
31
votes
3answers
7k views

Why are the Java 8 java.time classes missing a getMillis() method?

Java 8 has a whole new library for dates and times in the package java.time which is very welcome thing to anyone who has had to use JodaTime before or hassle with making it's own date processing ...
5
votes
2answers
2k views

Are Interfaces with Java 8 Virtual Extension Methods the Same Thing as Mixins?

This post describes a new feature in Java 8 called virtual extension methods (formerly called default methods, or defender methods). In the example provided, an interface has one method, which is ...
2
votes
2answers
374 views

Why would someone use @Native annotations?

link : http://download.java.net/jdk8/docs/api/java/lang/annotation/Native.html In Java 8, there will be @Native annotations. Indicates that a field defining a constant value may be referenced ...
12
votes
1answer
2k views

Reasons for removal of function types in Java 8

I have been trying to understand why the JDK 8 Lambda Expert Group (EG) decided not to include a new function type into the Java programming language. Going over the mailing list I found a thread ...
21
votes
2answers
7k 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? ...