I have the following code:
public Trail getNewestTrail() { return trails.stream().max(Comparator.comparing(Trail::getTimestamp)).orElseThrow(NoSuchElementException::new); } I am not seeing any error without having getNewestTrail declared as throwing the exception -- why?