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 stream's .min() and .max(): why does this compile?

Note: this question originates from a dead link which was a previous SO question, but here goes... See this code (…

java java-8 java-stream
Java 8 lambda get and remove element from list

Given a list of elements, I want to get the element with a given property and remove it from the …

java lambda java-8 java-stream
How to negate a method reference predicate

In Java 8, you can use a method reference to filter a stream, for example: Stream<String> s = ...; long …

java predicate java-8 negate
How do I use the new computeIfAbsent function?

I very much want to use Map.computeIfAbsent but it has been too long since lambdas in undergrad. Almost directly …

java dictionary lambda java-8
How to get UTC+0 date in Java 8?

I have problems with Date class in Java. Date class returns local machine date but i need UTC-0. I have …

java datetime java-8 java-time
Convert LocalDateTime to LocalDateTime in UTC

Convert LocalDateTime to LocalDateTime in UTC. LocalDateTime convertToUtc(LocalDateTime date) { //do conversion } I searched over net. But did not get …

java java-8 utc java-time
Java 8: Lambda-Streams, Filter by Method with Exception

I have a problem trying out the Lambda expressions of Java 8. Usually it works fine, but now I have methods …

java exception-handling lambda java-8
Ignore duplicates when producing map using streams

Map<String, String> phoneBook = people.stream() .collect(toMap(Person::getName, Person::getAddress)); I get java.lang.IllegalStateException: Duplicate …

java java-8 java-stream
java.time.format.DateTimeParseException: Text could not be parsed at index 21

I get the datetime value as created_at '2012-02-22T02:06:58.147Z' Read-only. The time at which this task …

java datetime java-8 java-time
How to check if element exists using a lambda expression?

Specifically, I have TabPane, and I would like to know if there is element with specific ID in it. So, …

java java-8 lambda