get()
on an Optional
without checking that it has a value.
Calling Optional.get()
on an empty Optional
instance will throw an exception.
Example:
void x(List<Integer> list) {
final Optional<Integer> optional =
list.stream().filter(x -> x > 10).findFirst();
final Integer result = optional.get(); // problem here
}