Top "Java-8" questions

Use this tag for questions specific to Java 8 which is version 8 (internal number 1.8) of the Java platform, released on 18 March 2014.

Java 8 Iterable.forEach() vs foreach loop

Which of the following is better practice in Java 8? Java 8: joins.forEach(join -> mIrc.join(mSession, join)); Java 7: …

java for-loop java-8 java-stream
Convert java.time.LocalDate into java.util.Date type

I want to convert java.time.LocalDate into java.util.Date type. Because I want to set the date into …

java java-8 java-time
How to get milliseconds from LocalDateTime in Java 8

I am wondering if there is a way to get current milliseconds since 1-1-1970 (epoch) using the new LocalDate, …

java datetime java-8 milliseconds java-time
Functional style of Java 8's Optional.ifPresent and if-not-Present?

In Java 8, I want to do something to an Optional object if it is present, and do another thing if …

java functional-programming java-8 optional
Using Java 8 to convert a list of objects into a string obtained from the toString() method

There are a lot of useful new things in Java 8. E.g., I can iterate with a stream over a …

java java-8 java-stream
:: (double colon) operator in Java 8

I was exploring the Java 8 source and found this particular part of code very surprising: //defined in IntPipeline.java @Override …

java java-8
Retrieving a List from a java.util.stream.Stream in Java 8

I was playing around with Java 8 lambdas to easily filter collections. But I did not find a concise way to …

collections lambda java-8 java-stream
How can I turn a List of Lists into a List in Java 8?

If I have a List<List<Object>>, how can I turn that into a List<…

java collections java-8
Java 8 Lambda function that throws exception?

I know how to create a reference to a method that has a String parameter and returns an int, it's: …

java lambda java-8
Java 8 Distinct by property

In Java 8 how can I filter a collection using the Stream API by checking the distinctness of a property of …

java collections java-8 java-stream distinct-values