I am trying to throw an unechecked runtime exception in a nested stream. For some reason, this seems not possible. Why?
See example below. Please note that the logic does not make much sense. It is just for demonstration purposes.
public static void main(String[] a) {
List<Integer> list = Arrays.asList(1, 2, 3, 4, 5);
list.stream()
.map(item -> list.stream()
.filter(item2 -> item.equals(item2))
.findFirst()
.orElseThrow(RuntimeException::new))
.collect(Collectors.toList());
}