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.

Return from lambda forEach() in java

I am trying to change some for-each loops to lambda forEach()-methods to discover the possibilities of lambda expressions. The …

java foreach lambda java-8 return-type
Adding up BigDecimals using Streams

I have a collection of BigDecimals (in this example, a LinkedList) that I would like to add together. Is it …

java bigdecimal java-8 java-stream
How to decompile to java files intellij idea

IDEA has a great built-in feature - decompiler. It works great.I can copy source code, but I cannot find …

java intellij-idea java-8 decompiling
Group by multiple field names in java 8

I found the code for grouping the objects by some field name from POJO. Below is the code for that: …

java java-8
Java 8 lambdas, Function.identity() or t->t

I have a question regarding the usage of the Function.identity() method. Imagine the following code: Arrays.asList("a", "b", "…

java lambda java-8 java-stream
Fetch first element which matches criteria

How to get first element that matches a criteria in a stream? I've tried this but doesn't work this.stops.…

java java-8 java-stream
Unable to obtain LocalDateTime from TemporalAccessor when parsing LocalDateTime (Java 8)

I am simply trying to convert a date string into a DateTime object in Java 8. Upon running the following lines: …

java datetime java-8 datetime-format
How to execute logic on Optional if not present?

I want to replace the following code using java8 Optional: public Obj getObjectFromDB() { Obj obj = dao.find(); if (obj != null) { …

java java-8 optional
Difference between `Optional.orElse()` and `Optional.orElseGet()`

I am trying to understand the difference between the Optional<T>.orElse() and Optional<T>.orElseGet() …

java java-8 optional
Why use Optional.of over Optional.ofNullable?

When using the Java 8 Optional class, there are two ways in which a value can be wrapped in an optional. …

java java-8 nullpointerexception null optional