Java 10 changes
Optional orElseThrow
orElseThrow()
has been added to Optional
as a replacement for get()
. It has the same behaviour but has clearer naming.
If the value is present it will be returned, otherwise a NoSuchElementException
is thrown.
.findFirst()
.orElseThrow();